Expand description
This module defines a load-balanced pool of services that adds new services when load is high.
The pool uses poll_ready as a signal indicating whether additional services should be spawned
to handle the current level of load. Specifically, every time poll_ready on the inner service
returns Ready, Pool consider that a 0, and every time it returns Pending, Pool
considers it a 1. Pool then maintains an exponential moving
average over those
samples, which gives an estimate of how often the underlying service has been ready when it was
needed “recently” (see Builder::urgency). If the service is loaded (see
Builder::loaded_above), a new service is created and added to the underlying Balance.
If the service is underutilized (see Builder::underutilized_below) and there are two or
more services, then the latest added service is removed. In either case, the load estimate is
reset to its initial value (see Builder::initial to prevent services from being rapidly
added or removed.
Structs§
- Builder
 - A builder that lets you configure how a 
Pooldetermines whether the underlying service is loaded or not. See the module-level documentation and the builder’s methods for details. - Pool
 - A dynamically sized, load-balanced pool of 
Serviceinstances. - Pool
Discoverer  - A wrapper around 
MakeServicethat discovers a new service when load is high, and removes a service when load is low. SeePool.