Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ergonomics issue with 0.16 #19

Open
@ufoscout

Description

@ufoscout

Hi,

while upgrading a project from rust_postgres 0.15 to 0.17 and r2d2_postgres 0.14 to 0.16, we have some troubles with the new definition ofPostgresConnectionManager<T> that contains a new generic parameter<T>.
The problem is that the r2d2 pool returns aPooledConnection that now has the very same generic parameter<T> that, as a consequence, has to be redeclared in every place where the connection is used.

For example, our project structure follows the Domain Driven Design principle, then:

  • we have a set of Repositories that use aPooledConnection, so they all have to declare the<T> generic param
  • we have a set of Services that use the Repositories, so all Services need to declare<T> too
  • we have a set of Controllers that use the Services, so all Controllers need to declare<T>
  • and so on...

In the end, this<T> generic is declared literally everywhere.

In addition, the rust_postgresClient has no generic parameters at all so it is not clear why thePooledConnection requires it.

I don't know if it is feasible, but the issue could be fixed by changing the signature in the r2d2 pool from:

pubfnget(&self) ->Result<PooledConnection<M>,Error>;

to

pubfnget(&self) ->Result<PooledConnection<M::Connection>,Error>;

Or, maybe, the<T> param can be boxed in thePostgresConnectionManager struct:

#[derive(Debug)]pubstructPostgresConnectionManager{config:Config,tls_connector:Box<MakeTlsConnect<Socket,TlsConnect=Send,Stream=Send, ... >>,}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp