pub struct RandomClassifier { /* private fields */ }Expand description
Stateless weighted classifier used by random fall-through routing.
Implementations§
Source§impl RandomClassifier
impl RandomClassifier
Sourcepub fn new(
targets: Vec<String>,
weights: Option<Vec<f64>>,
seed: Option<u64>,
) -> Result<Self>
pub fn new( targets: Vec<String>, weights: Option<Vec<f64>>, seed: Option<u64>, ) -> Result<Self>
Creates a classifier over ordered target names.
Missing weights default to one per target. Explicit weights are relative,
follow target order, and need not sum to one. Zero disables a target.
Missing seed uses entropy-backed randomness.
§Errors
Returns an error when targets are empty or duplicated, or when explicit weights have the wrong length, are negative or non-finite, or contain no positive value.
Trait Implementations§
Source§impl<S> Classifier<S> for RandomClassifierwhere
S: Send + 'static,
impl<S> Classifier<S> for RandomClassifierwhere
S: Send + 'static,
Source§fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
_request: &'life2 mut Request,
_driver: Option<&'life3 Driver>,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn score<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_state: &'life1 mut S,
_request: &'life2 mut Request,
_driver: Option<&'life3 Driver>,
) -> Pin<Box<dyn Future<Output = Result<(Classification, Option<Response>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Score the classifier’s targets given the current state and request. Read more
Auto Trait Implementations§
impl !Freeze for RandomClassifier
impl !RefUnwindSafe for RandomClassifier
impl Send for RandomClassifier
impl Sync for RandomClassifier
impl Unpin for RandomClassifier
impl UnsafeUnpin for RandomClassifier
impl UnwindSafe for RandomClassifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more