stygian-proxy
High-performance, resilient proxy rotation for the Stygian scraping ecosystem.
Features
| Feature | Description |
|---|---|
| Rotation strategies | Round-robin, random, weighted, least-used — all pluggable via trait |
| Circuit breakers | Per-proxy Closed → Open → HalfOpen state machine; unhealthy proxies are skipped automatically |
| Health checking | Background async health checker with configurable interval and per-proxy scoring |
| RAII proxy handles | ProxyHandle records success/failure on drop; no manual bookkeeping |
| SOCKS support | SOCKS4/5 via reqwest (socks feature flag) |
| Graph integration | ProxyManagerPort trait wires into stygian-graph HTTP adapters (graph feature) |
| Browser integration | BrowserProxySource binds pool proxies into stygian-browser contexts (browser feature) |
| Zero external deps | In-memory storage only — no database required |
Installation
[]
= "0.2"tokio = { version = "1", features = ["full"] }
Enable optional features:
# SOCKS4/5 proxy support
= { = "0.2", = ["socks"] }
# Integration with stygian-graph HTTP adapters
= { = "0.2", = ["graph"] }
# Integration with stygian-browser pool
= { = "0.2", = ["browser"] }
Quick Start
use ;
use Arc;
use Duration;
async
Rotation Strategies
| Strategy | Constructor | Behaviour |
|---|---|---|
RoundRobinStrategy |
ProxyManager::with_round_robin |
Cycles through healthy proxies in order |
RandomStrategy |
ProxyManager::with_random |
Picks a healthy proxy at random each time |
WeightedStrategy |
ProxyManager::with_weighted |
Selects proportionally to each proxy's weight field |
LeastUsedStrategy |
ProxyManager::with_least_used |
Prefers the proxy with the lowest total request count |
Custom strategies implement RotationStrategy:
use ;
use ProxyResult;
use async_trait;
;
Circuit Breaker
Each proxy has its own CircuitBreaker. After circuit_open_threshold consecutive failures the breaker opens, and the proxy is excluded from rotation for circuit_half_open_after. After that window the proxy is tried once in HalfOpen state — a success closes it; another failure reopens it.
use ;
use Arc;
use Duration;
let config = ProxyConfig ;
let manager = with_round_robin?;
If a ProxyHandle is dropped without calling mark_success(), the circuit breaker records a failure automatically.
Health Checking
ProxyManager::start() spawns a background task that probes each proxy on a configurable interval and updates per-proxy health scores:
use ;
use Arc;
use Duration;
let config = ProxyConfig ;
let manager = with_round_robin?;
let = manager.start;
// Graceful shutdown
cancel_token.cancel;
stygian-graph Integration
With the graph feature, the pool implements ProxyManagerPort so stygian-graph adapters can rotate proxies per-request:
= { = "0.2", = ["graph"] }
= "0.2"
use ;
use ProxyConfig;
use Arc;
let manager = with_round_robin?;
// Pass as Arc<dyn ProxyManagerPort> to RestApiAdapter or HttpAdapter
stygian-browser Integration
With the browser feature, BrowserProxySource feeds live pool proxies into stygian-browser contexts:
= { = "0.2", = ["browser"] }
= "0.2"
use ;
use ProxyConfig;
use BrowserConfig;
use Arc;
let manager = new;
let bridge = new;
// bridge.next_proxy_url().await? → inject into BrowserConfig::proxy
License
AGPL-3.0-only OR LicenseRef-Commercial — see LICENSE and LICENSE-COMMERCIAL.md.