Skip to main content

Module stickiness

Module stickiness 

Source
Expand description

Per-vendor session stickiness policy.

The 2026 scraping guide (see docs/dev/project/scraping-guide-2026-llm-context.md §“PROXY PROVIDERS AND TYPES”) describes an anti-bot-specific stickiness matrix:

VendorRecommended stickiness
AkamaiStatic / ISP IP, sticky for the lifetime of a long session.
PerimeterXFresh session per domain (Camoufox + residential flow).
DataDomeNo stickiness — fresh proxy per request; mobile carrier wins.
KasadaFresh session per domain.
CloudflareShort (≈5 min) sticky window — cf_clearance re-issue cadence.
ImpervaMedium (≈15 min) sticky window.
everything elseFresh proxy per request (safest default for unknown vendors).

VendorStickinessMap encodes that matrix as a typed BTreeMap<VendorId, StickinessPolicy> so the SessionMap and ProxyManager can pick the correct sticky slot automatically when a session is requested for (domain, vendor).

§Feature flag

The data types in this module are always compiled (so external adapters can build a VendorStickinessMap without enabling the feature). The wiring into ProxyManager::acquire_for_domain_with_vendor is gated behind the vendor-stickiness cargo feature (off by default; wired into the full aggregator).

§Example

use std::time::Duration;
use stygian_proxy::stickiness::{StickinessPolicy, VendorStickinessMap};
use stygian_proxy::types::VendorId;

// Built-in defaults from the 2026 guide.
let defaults = VendorStickinessMap::with_builtin_defaults();
assert_eq!(
    defaults.for_vendor(VendorId::Akamai),
    StickinessPolicy::StickyForTtl { ttl: Duration::from_mins(30) }
);
assert_eq!(
    defaults.for_vendor(VendorId::DataDome),
    StickinessPolicy::FreshPerRequest
);
assert_eq!(
    defaults.for_vendor(VendorId::Unknown),
    StickinessPolicy::FreshPerRequest

); // unknown vendors fall back to the safest default

// Operators can override individual entries before applying built-ins.
let custom = VendorStickinessMap::with_builtin_defaults()
    .with_override(VendorId::Akamai, StickinessPolicy::StickyForever);
assert_eq!(custom.for_vendor(VendorId::Akamai), StickinessPolicy::StickyForever);

Structs§

VendorStickinessMap
BTreeMap-backed stickiness policy keyed by anti-bot VendorId.

Enums§

StickinessPolicy
Session stickiness policy keyed by anti-bot VendorId.