pub struct Builder { /* private fields */ }
balance
only.Expand description
A builder that lets you configure how a Pool
determines whether the underlying service is
loaded or not. See the module-level documentation and the builder’s methods for
details.
Implementations
sourceimpl Builder
impl Builder
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with default values for all load settings.
If you just want to use the defaults, you can just use Pool::new
.
sourcepub fn underutilized_below(&mut self, low: f64) -> &mut Self
pub fn underutilized_below(&mut self, low: f64) -> &mut Self
When the estimated load (see the module-level docs) drops below this threshold, and there are at least two services active, a service is removed.
The default value is 0.01. That is, when one in every 100 poll_ready
calls return
Pending
, then the underlying service is considered underutilized.
sourcepub fn loaded_above(&mut self, high: f64) -> &mut Self
pub fn loaded_above(&mut self, high: f64) -> &mut Self
When the estimated load (see the module-level docs) exceeds this
threshold, and no service is currently in the process of being added, a new service is
scheduled to be added to the underlying Balance
.
The default value is 0.5. That is, when every other call to poll_ready
returns
Pending
, then the underlying service is considered highly loaded.
sourcepub fn initial(&mut self, init: f64) -> &mut Self
pub fn initial(&mut self, init: f64) -> &mut Self
The initial estimated load average.
This is also the value that the estimated load will be reset to whenever a service is added or removed.
The default value is 0.1.
sourcepub fn urgency(&mut self, alpha: f64) -> &mut Self
pub fn urgency(&mut self, alpha: f64) -> &mut Self
How aggressively the estimated load average is updated.
This is the α parameter of the formula for the exponential moving average, and dictates how quickly new samples of the current load affect the estimated load. If the value is closer to 1, newer samples affect the load average a lot (when α is 1, the load average is immediately set to the current load). If the value is closer to 0, newer samples affect the load average very little at a time.
The given value is clamped to [0,1]
.
The default value is 0.05, meaning, in very approximate terms, that each new load sample affects the estimated load by 5%.
sourcepub fn max_services(&mut self, limit: Option<usize>) -> &mut Self
pub fn max_services(&mut self, limit: Option<usize>) -> &mut Self
The maximum number of backing Service
instances to maintain.
When the limit is reached, the load estimate is clamped to the high load threshhold, and no new service is spawned.
No maximum limit is imposed by default.
Trait Implementations
impl Copy for Builder
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more