sfackler / r2d2

A generic connection pool for Rust
Apache License 2.0
1.51k stars 82 forks source link

Add `Pool#get_immediately` #33

Closed sgrif closed 7 years ago

sgrif commented 7 years ago

This method behaves the same as get, except that it will not attempt to establish new connections, and will not wait for a connection to become available. This is useful for users who may wish to attempt to parallelize a task over multiple connections, but only if there are enough idle connections already available.

sfackler commented 7 years ago

Sounds good to me! I think the name try_get matches up a bit more with things like the stdlib Mutex though.

sfackler commented 7 years ago

Thanks!

sfackler commented 7 years ago

@sgrif I noticed that when #32 was rebased over this try_get calls establish_idle_connections. What are the intended semantics with respect to new connection creation?

sgrif commented 7 years ago

I'd expect try_get to cause idle connections to be opened if needed -- Since establish_idle_connections shouldn't block for any significant amount of time, I don't think it's an issue

sfackler commented 7 years ago

Ok, but not go above min_idle (like we do in https://github.com/sfackler/r2d2/blob/master/src/lib.rs#L419-L421)?