pub struct ScatterProxy { /* private fields */ }Expand description
The main entry point. Manages proxy pool, scheduling, and background tasks.
Implementations§
Source§impl ScatterProxy
impl ScatterProxy
Sourcepub async fn new(
config: ScatterProxyConfig,
classifier: impl BodyClassifier,
) -> Result<Self, ScatterProxyError>
pub async fn new( config: ScatterProxyConfig, classifier: impl BodyClassifier, ) -> Result<Self, ScatterProxyError>
Create a new ScatterProxy from config and a body classifier.
This is an async constructor that fetches proxies, restores persisted state, and spawns all background tasks (scheduler, persistence, metrics logging, source refresh).
Sourcepub async fn submit(&self, request: Request) -> TaskHandle
pub async fn submit(&self, request: Request) -> TaskHandle
Submit a single request for proxied execution.
Blocks until the pool has capacity, then returns a TaskHandle whose
.await blocks until a successful proxied response is obtained. The
scheduler retries internally forever — use TaskHandle::with_timeout
or wrap with tokio::time::timeout to impose a caller-side deadline.
Sourcepub fn try_submit(
&self,
request: Request,
) -> Result<TaskHandle, ScatterProxyError>
pub fn try_submit( &self, request: Request, ) -> Result<TaskHandle, ScatterProxyError>
Non-blocking submit. Returns Err(PoolFull) immediately when the pool
is at capacity instead of blocking.
Sourcepub async fn submit_batch(&self, requests: Vec<Request>) -> Vec<TaskHandle>
pub async fn submit_batch(&self, requests: Vec<Request>) -> Vec<TaskHandle>
Submit a batch of requests for proxied execution, blocking until the pool has capacity for each request sequentially.
Sourcepub fn try_submit_batch(
&self,
requests: Vec<Request>,
) -> Result<Vec<TaskHandle>, ScatterProxyError>
pub fn try_submit_batch( &self, requests: Vec<Request>, ) -> Result<Vec<TaskHandle>, ScatterProxyError>
Non-blocking atomic batch submit. If the pool doesn’t have enough capacity for the entire batch, the whole batch is rejected.
Sourcepub async fn submit_timeout(
&self,
request: Request,
timeout: Duration,
) -> Result<TaskHandle, ScatterProxyError>
pub async fn submit_timeout( &self, request: Request, timeout: Duration, ) -> Result<TaskHandle, ScatterProxyError>
Submit with a deadline on the submission step itself.
Blocks up to timeout waiting for pool capacity. Returns
Err(Timeout) if no slot opens in time. Once a slot is obtained the
returned TaskHandle blocks indefinitely (retry forever) until a
response arrives — use TaskHandle::with_timeout to bound that step.
Sourcepub fn metrics(&self) -> PoolMetrics
pub fn metrics(&self) -> PoolMetrics
Build a PoolMetrics snapshot from all internal components.