Skip to main content

stygian_proxy/
lib.rs

1//! # stygian-proxy
2#![allow(clippy::multiple_crate_versions)]
3//!
4//! High-performance, resilient proxy rotation for the Stygian scraping ecosystem.
5//!
6//! ## Features
7//!
8//! - Pluggable rotation strategies: round-robin, random, weighted, least-used
9//! - Per-proxy latency and success-rate tracking via atomics
10//! - Async health checker with configurable intervals
11//! - Per-proxy circuit breaker (`Closed -> Open -> HalfOpen`)
12//! - In-memory proxy pool (no external DB required)
13//! - `graph` feature: [`ProxyManagerPort`] trait for stygian-graph HTTP adapters
14//! - `browser` feature: per-context proxy binding for stygian-browser
15//!
16//! ## Quick start
17//!
18//! ```rust,no_run
19//! use stygian_proxy::error::ProxyResult;
20//!
21//! fn main() -> ProxyResult<()> {
22//!     // ProxyManager construction added in T12 (proxy-manager task)
23//!     Ok(())
24//! }
25//! ```
26
27pub mod circuit_breaker;
28pub mod error;
29pub mod fetcher;
30pub mod health;
31pub mod manager;
32pub mod session;
33pub mod storage;
34pub mod strategy;
35pub mod types;
36
37#[cfg(feature = "graph")]
38pub mod graph;
39
40#[cfg(feature = "browser")]
41pub mod browser;
42
43#[cfg(feature = "tls-profiled")]
44pub mod http_client;
45
46pub mod routing;
47
48/// MCP (Model Context Protocol) server — exposes proxy pool tools
49#[cfg(feature = "mcp")]
50pub mod mcp;
51
52// Top-level re-exports
53pub use circuit_breaker::{CircuitBreaker, STATE_CLOSED, STATE_HALF_OPEN, STATE_OPEN};
54pub use error::{ProxyError, ProxyResult};
55#[cfg(feature = "dns-fetcher")]
56pub use fetcher::DnsTxtFetcher;
57pub use fetcher::{
58    FreeApiProxiesFetcher, FreeListFetcher, FreeListSource, ProxyFetcher, load_from_fetcher,
59};
60pub use health::{HealthChecker, HealthMap};
61pub use manager::{PoolStats, ProxyHandle, ProxyManager, ProxyManagerBuilder};
62pub use session::{SessionMap, StickyPolicy};
63pub use storage::MemoryProxyStore;
64pub use strategy::{
65    BoxedRotationStrategy, LeastUsedStrategy, ProxyCandidate, RandomStrategy, RotationStrategy,
66    RoundRobinStrategy, WeightedStrategy, capable_healthy_candidates,
67};
68pub use types::{
69    CapabilityRequirement, ProfiledRequestMode, Proxy, ProxyCapabilities, ProxyConfig,
70    ProxyMetrics, ProxyRecord, ProxyType, RoutingPath,
71};
72
73#[cfg(feature = "graph")]
74pub use graph::{BoxedProxyManager, NoopProxyManager, ProxyManagerPort};
75
76#[cfg(feature = "browser")]
77pub use browser::{BrowserProxySource, ProxyManagerBridge};
78
79#[cfg(feature = "tls-profiled")]
80pub use http_client::{ProfiledRequester, ProfiledRequesterError};