Struct tower_balance::pool::Builder [−][src]
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
impl Builder
[src]
pub fn new() -> Self
[src]
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
.
pub fn underutilized_below(&mut self, low: f64) -> &mut Self
[src]
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.
pub fn loaded_above(&mut self, high: f64) -> &mut Self
[src]
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.
pub fn initial(&mut self, init: f64) -> &mut Self
[src]
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.
pub fn urgency(&mut self, alpha: f64) -> &mut Self
[src]
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%.
pub fn max_services(&mut self, limit: Option<usize>) -> &mut Self
[src]
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.
pub fn build<MS, Target, Request>(
&self,
make_service: MS,
target: Target
) -> Pool<MS, Target, Request> where
MS: MakeService<Target, Request>,
MS::Service: Load,
<MS::Service as Load>::Metric: Debug,
MS::MakeError: Into<Box<dyn Error + Send + Sync>>,
MS::Error: Into<Box<dyn Error + Send + Sync>>,
Target: Clone,
[src]
&self,
make_service: MS,
target: Target
) -> Pool<MS, Target, Request> where
MS: MakeService<Target, Request>,
MS::Service: Load,
<MS::Service as Load>::Metric: Debug,
MS::MakeError: Into<Box<dyn Error + Send + Sync>>,
MS::Error: Into<Box<dyn Error + Send + Sync>>,
Target: Clone,
See Pool::new
.
Trait Implementations
impl Clone for Builder
[src]
impl Copy for Builder
[src]
impl Debug for Builder
[src]
impl Default for Builder
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,