pub trait ProxySource:
Send
+ Sync
+ Debug
+ 'static {
// Required method
fn bind_proxy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, Box<dyn ProxyLease>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Source of proxies for browser context pools.
Implement this trait and pass an Arc<dyn ProxySource> to
BrowserConfig::builder().proxy_source(...)
to enable per-context proxy rotation with circuit-breaker support.
Each call to bind_proxy acquires a proxy URL
and an RAII ProxyLease that must be held for the lifetime of the
browser instance.
stygian-proxy provides a ready-made implementation via
ProxyManagerBridge when compiled with the browser feature.
§Example
use std::sync::Arc;
use async_trait::async_trait;
use stygian_browser::proxy::{ProxyLease, ProxySource, DirectLease};
use stygian_browser::error::Result;
#[derive(Debug)]
struct RoundRobinProxy {
urls: Vec<String>,
}
#[async_trait]
impl ProxySource for RoundRobinProxy {
async fn bind_proxy(&self) -> Result<(String, Box<dyn ProxyLease>)> {
let url = self.urls[0].clone(); // simplified — real impl would rotate
Ok((url, Box::new(DirectLease)))
}
}
let source = Arc::new(RoundRobinProxy { urls: vec!["http://p.example.com:8080".into()] });
let cfg = stygian_browser::BrowserConfig::builder()
.proxy_source(source)
.build();Required Methods§
Sourcefn bind_proxy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, Box<dyn ProxyLease>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bind_proxy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, Box<dyn ProxyLease>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Acquire the next proxy URL and an RAII lease handle.
The returned (url, lease) pair must be used together:
urlis passed as the--proxy-serverChrome launch argument.leasemust be held for the lifetime of that browser instance. CallProxyLease::mark_successon clean session exit.
§Errors
Returns crate::error::BrowserError::ProxyUnavailable if no proxy
is currently available (e.g. circuit breaker open, pool empty).