pub struct ProxyPool { /* private fields */ }Expand description
A rotatable pool of upstream proxy URLs.
Implementations§
Source§impl ProxyPool
impl ProxyPool
Sourcepub fn new(
urls: impl IntoIterator<Item = String>,
strategy: RotationStrategy,
) -> Self
pub fn new( urls: impl IntoIterator<Item = String>, strategy: RotationStrategy, ) -> Self
Build a pool from upstream proxy URLs (untagged). Duplicate and empty URLs are dropped.
The initially selected endpoint is the first one for
RotationStrategy::RoundRobin, or a random one for
RotationStrategy::Random.
Sourcepub fn with_endpoints(
endpoints: impl IntoIterator<Item = (String, Option<CountryCode>)>,
strategy: RotationStrategy,
) -> Self
pub fn with_endpoints( endpoints: impl IntoIterator<Item = (String, Option<CountryCode>)>, strategy: RotationStrategy, ) -> Self
Build a pool from (url, country) pairs, where country tags the proxy’s
exit country for proxy-led locale derivation. Duplicate/empty URLs dropped.
Sourcepub fn healthy_count(&self) -> usize
pub fn healthy_count(&self) -> usize
Number of endpoints currently marked healthy.
Sourcepub fn selected_country(&self) -> Option<CountryCode>
pub fn selected_country(&self) -> Option<CountryCode>
The tagged exit country of the currently selected proxy, if any.
Sourcepub fn rotate(&mut self) -> Option<String>
pub fn rotate(&mut self) -> Option<String>
Retire the current endpoint and select the next healthy one.
Marks the current endpoint unhealthy (so rotation never returns to a
known-blocked proxy), then selects the next healthy endpoint per the
RotationStrategy. Returns the newly selected URL, or None when no
healthy endpoints remain.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProxyPool
impl RefUnwindSafe for ProxyPool
impl Send for ProxyPool
impl Sync for ProxyPool
impl Unpin for ProxyPool
impl UnsafeUnpin for ProxyPool
impl UnwindSafe for ProxyPool
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more