Comments (4)
I wonder if this is really a bug with tokio-postgres
. If it had an impl MakeTlsConnect for Box<dyn MakeTlsConnect>
, then you could just box whatever you have into a trait object and things would work.
Any thoughts @sfackler?
from bb8.
Just want to pile on here to say I'm having the same issue -- in fact I'm trying to store the connection manager and the pool that gets created. At first I tried to use the code that @ufoscout wrote in sfackler/r2d2-postgres#19, but I didn't want to stray that far from the beaten path so I ended up with this monstrosity:
type ConnMgr = PostgresConnectionManager<Box<dyn MakeTlsConnect<Socket, TlsConnect=dyn Send, Stream=dyn Send, Error=dyn Error>>>;
Now I'm just running into the same problem with Pool<M>
where M
is something that implements ManageConnection
, and I'm struggling on how to fill the Connection
and Error
type variables. While I'm sure this really cleaned up the code for r2d2
it's made it a lot harder to use. Haven't been able to figure out how to do it for Pool
so now I've moved making the pool to the area before I loop forever handling requests (it's a bit of an "actor"-ish setup).
[EDIT] - In the end I just stopped trying to own both of those in my own setup. This has made it really difficult to use -- implementing MakeTlsConnect
for Box<dyn MakeTlsConnect>
would definitely solve this it looks like though, since that's exactly what I"m missing -- is that OK as a path forward?
from bb8.
I have nothing to add here, but I just wanted to comment that as a beginner to Rust, the usage of this is very confusing. Even as an experienced programmer just getting into Rust, it's extremely annoying to be able to accept any generic type for PostgresConnectionManager
. From what I can tell, you can either use a type like NoTls
directly (which I assume makes using TLS impossible?), or use the aforementioned type, which just looks ugly.
If you go for the second option above, you run into a huge problem when having your own custom error enums when implementing the From
trait to turn say a RunError
into your own error type, because you're forced into using generics.
Would it not be possible to just have some underlying connection manager of some sort that is capable of using TLS and non-TLS connections? I'm not sure how the internals work, but surely it would be possible to have some sort of abstraction to make this possible?
from bb8.
It might be possible to write enums that wrap over well-known types implementing MakeTlsConnect
, TlsConnect
, AsyncRead
, AsyncWrite
and TlsStream
. I probably won't be working on that, but if someone made fairly complete implementation I could review and merge it.
from bb8.
Related Issues (20)
- Time taken to get a connection from bb8 redis pool is very high HOT 2
- Unable to use bb8-redis pool connection to execute `query_async` commands on redis HOT 3
- Why bb8-redis can't support redis features? HOT 3
- ACL support for redis HOT 2
- Error sink not called unless debugger is attached with breakpoints HOT 2
- Reentrant deadlock HOT 5
- Reaper default frequency conflicts with other settings
- Unable to connect to secure client using bb8-redis HOT 2
- TimedOut error when has_broken = true HOT 8
- add a tag for v0.8.1 HOT 2
- Expose internal connection type in some way HOT 2
- Support for pool creation without requiring initial connection HOT 2
- Unusually slow to give redis connections HOT 7
- Close pool and all connections? HOT 1
- Support for pool creation with concurrent connections creation HOT 5
- Attempt to subtract with overflow, new version 8.2 HOT 5
- Timeout Issue with bb8-redis 0.14.0 on GCP Memorystore Redis HOT 5
- Changelog HOT 1
- Remove async-trait in favor of impl trait and native async in impls HOT 6
- Support async behavior to determine if the connection is no longer usable in ManageConnection Trait HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bb8.