Struct tk_pool::uniform::Config [] [src]

pub struct Config { /* fields omitted */ }

Configuration of the connection pool

Note default configuration doesn't make sense for most cases. Please tweak at least Config::connections_per_address.

Also make sure to use eager_connections() if you expect performance.

Methods

impl Config
[src]

Create a new config with default configuration

Default configuration has connections_per_address: 1 which is only useful if you have synchronous workers and only one of them is bound to every socket, or if there is a virtually infinite resources on the other side (comparing to the number of requests we are going to do) and good pipelining support.

Establish connections and keep them open even if there are no requests.

Lazy connections are nicer when you have mostly idle connection pool and don't need sub-millisecond latency. The connection is established only when there are no other connections that can serve a request.

Lazy connections are enabled by default because it what makes most sense if you have HashMap<Hostname, UniformMx> and this is how most connections pools work in other languages.

Note that pool with lazy connections will return NotReady when there are free connections, but starts a new ones asynchronously. Also it will not establish new connections when there are no backpressure on existing connections even if not all peers are connected to yet. So you may get a skew in cluster load, especially if you support may pipelined requests on a single connection.

Set the number of connections per address

This kind of limit may look awkward for a connection pool. You used to opening fixed number of connections per connection pool rather than per backend address. But consider there are lots of workers (say 100 or 1000), and every worker has limited number of resources. So you want to have a number of connections proportional to actual workers there rather than arbitrarily chosen number of connections.

Surely it doesn't work well for other cases. This is why we have multiple multiplexer implementations.

Create a Arc'd config clone to pass to the constructor

This is just a convenience method.

Trait Implementations

impl Clone for Config
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Config
[src]

Formats the value using the given formatter.