pub struct RandomStrategy;Expand description
Selects a healthy proxy uniformly at random on each call.
Stateless — no lock or shared counter required.
§Example
use stygian_proxy::strategy::{RandomStrategy, RotationStrategy, ProxyCandidate};
use stygian_proxy::types::ProxyMetrics;
use std::sync::Arc;
use uuid::Uuid;
let strategy = RandomStrategy;
let candidates = vec![
ProxyCandidate { id: Uuid::new_v4(), weight: 1, metrics: Arc::new(ProxyMetrics::default()), healthy: true },
];
strategy.select(&candidates).await.unwrap();Trait Implementations§
Source§impl Clone for RandomStrategy
impl Clone for RandomStrategy
Source§fn clone(&self) -> RandomStrategy
fn clone(&self) -> RandomStrategy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RandomStrategy
impl Debug for RandomStrategy
Source§impl Default for RandomStrategy
impl Default for RandomStrategy
Source§fn default() -> RandomStrategy
fn default() -> RandomStrategy
Returns the “default value” for a type. Read more
Source§impl RotationStrategy for RandomStrategy
impl RotationStrategy for RandomStrategy
Source§fn select<'a, 'life0, 'async_trait>(
&'life0 self,
candidates: &'a [ProxyCandidate],
) -> Pin<Box<dyn Future<Output = ProxyResult<&'a ProxyCandidate>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn select<'a, 'life0, 'async_trait>(
&'life0 self,
candidates: &'a [ProxyCandidate],
) -> Pin<Box<dyn Future<Output = ProxyResult<&'a ProxyCandidate>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Select one candidate from
candidates. Read moreimpl Copy for RandomStrategy
Auto Trait Implementations§
impl Freeze for RandomStrategy
impl RefUnwindSafe for RandomStrategy
impl Send for RandomStrategy
impl Sync for RandomStrategy
impl Unpin for RandomStrategy
impl UnsafeUnpin for RandomStrategy
impl UnwindSafe for RandomStrategy
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