pub enum StickinessPolicy {
StickyForever,
StickyForTtl {
ttl: Duration,
},
StickyForRequestCount {
max_requests: u32,
},
FreshPerRequest,
FreshPerDomain,
}Expand description
Session stickiness policy keyed by anti-bot VendorId.
Different vendors reward different proxy-rotation cadences:
Akamaiaccumulates trust on a consistent ISP IP, so the session should be sticky for the whole scrape lifetime.Cloudflarere-issuescf_clearancecookies on a short cadence, so a 5 min sticky window matches the re-issue cadence and avoids burning the cookie on a single use.PerimeterX/Kasadaflag frequent proxy changes on the same domain, so each domain request should pick a fresh proxy.DataDomedoesn’t care about stickiness — it scores mobile carriers above all else — so the safe default is fresh per request.- Everything else falls back to
FreshPerRequestso an unknown vendor can never inherit a permissive sticky policy by accident.
Copy + Eq + Hash + Display + Debug for ergonomic logging and use as
a value type.
§Example
use std::time::Duration;
use stygian_proxy::stickiness::StickinessPolicy;
assert_eq!(
StickinessPolicy::StickyForTtl { ttl: Duration::from_mins(30) },
StickinessPolicy::StickyForTtl { ttl: Duration::from_mins(30) }
);
assert_eq!(format!("{}", StickinessPolicy::FreshPerRequest), "fresh_per_request");Variants§
StickyForever
Pin the same proxy for the entire process lifetime (or until the bound proxy fails its circuit breaker).
StickyForTtl
Pin the same proxy for a fixed TTL; pick fresh after expiry.
StickyForRequestCount
Pin the same proxy for at most max_requests requests; reset on
each request. Not currently enforced at the
SessionMap layer — the policy is
treated as FreshPerRequest when consulted by
acquire_session.
Kept in the enum for future per-request counters.
FreshPerRequest
Pick a fresh proxy for every request. No domain→proxy binding is created or retained.
FreshPerDomain
Pick a fresh proxy per domain request, evicting any prior binding.
The “per domain” qualifier means a request to a different domain for the same vendor reuses its own binding; a request to the same domain forces fresh.
Trait Implementations§
Source§impl Clone for StickinessPolicy
impl Clone for StickinessPolicy
Source§fn clone(&self) -> StickinessPolicy
fn clone(&self) -> StickinessPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StickinessPolicy
Source§impl Debug for StickinessPolicy
impl Debug for StickinessPolicy
Source§impl<'de> Deserialize<'de> for StickinessPolicy
impl<'de> Deserialize<'de> for StickinessPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for StickinessPolicy
impl Display for StickinessPolicy
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Stable, lower-case wire label for log output.
§Example
use std::time::Duration;
use stygian_proxy::stickiness::StickinessPolicy;
assert_eq!(format!("{}", StickinessPolicy::FreshPerRequest), "fresh_per_request");
assert_eq!(format!("{}", StickinessPolicy::StickyForever), "sticky_forever");
assert_eq!(
format!("{}", StickinessPolicy::StickyForTtl { ttl: Duration::from_secs(60) }),
"sticky_for_ttl(60s)"
);impl Eq for StickinessPolicy
Source§impl Hash for StickinessPolicy
impl Hash for StickinessPolicy
Source§impl PartialEq for StickinessPolicy
impl PartialEq for StickinessPolicy
Source§fn eq(&self, other: &StickinessPolicy) -> bool
fn eq(&self, other: &StickinessPolicy) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for StickinessPolicy
impl Serialize for StickinessPolicy
impl StructuralPartialEq for StickinessPolicy
Auto Trait Implementations§
impl Freeze for StickinessPolicy
impl RefUnwindSafe for StickinessPolicy
impl Send for StickinessPolicy
impl Sync for StickinessPolicy
impl Unpin for StickinessPolicy
impl UnsafeUnpin for StickinessPolicy
impl UnwindSafe for StickinessPolicy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.