pub struct ProxyPool {
pub config: PoolConfig,
pub pools: Arc<RwLock<HashMap<String, Vec<ProxyItem>>>>,
pub ip_providers: Arc<Mutex<HashMap<String, Arc<Box<dyn IpProxyLoader>>>>>,
pub stats: Arc<RwLock<PoolStats>>,
}Fields§
§config: PoolConfig§pools: Arc<RwLock<HashMap<String, Vec<ProxyItem>>>>§ip_providers: Arc<Mutex<HashMap<String, Arc<Box<dyn IpProxyLoader>>>>>§stats: Arc<RwLock<PoolStats>>Implementations§
Source§impl ProxyPool
impl ProxyPool
pub fn new(config: PoolConfig) -> Self
pub async fn add_tunnel(&self, tunnel: Tunnel)
pub async fn add_ip_provider(&self, provider: Box<dyn IpProxyLoader>)
pub async fn add_static_ip_proxy(&self, item: ProxyItem)
Sourcepub async fn get_proxy(&self, provider_name: Option<&str>) -> Result<ProxyEnum>
pub async fn get_proxy(&self, provider_name: Option<&str>) -> Result<ProxyEnum>
Gets a proxy, with load balancing and failover.
Sourcepub async fn get_best_tunnel(&self) -> Option<ProxyEnum>
pub async fn get_best_tunnel(&self) -> Option<ProxyEnum>
Gets the highest-quality tunnel proxy.
Sourcepub async fn report_proxy_result(
&self,
proxy: &ProxyEnum,
success: bool,
response_time: Option<Duration>,
) -> Result<()>
pub async fn report_proxy_result( &self, proxy: &ProxyEnum, success: bool, response_time: Option<Duration>, ) -> Result<()>
Reports the outcome of using a proxy.
Sourcepub async fn report_success(
&self,
proxy: &ProxyEnum,
response_time: Option<Duration>,
) -> Result<()>
pub async fn report_success( &self, proxy: &ProxyEnum, response_time: Option<Duration>, ) -> Result<()>
Reports a successful proxy use.
Sourcepub async fn report_failure(&self, proxy: &ProxyEnum) -> Result<()>
pub async fn report_failure(&self, proxy: &ProxyEnum) -> Result<()>
Reports a failed proxy use.
Sourcepub async fn get_pool_status(&self) -> HashMap<String, usize>
pub async fn get_pool_status(&self) -> HashMap<String, usize>
Gets the pool status.
Sourcepub async fn health_check(&self) -> Result<()>
pub async fn health_check(&self) -> Result<()>
Runs a health check.
Auto Trait Implementations§
impl !RefUnwindSafe for ProxyPool
impl !UnwindSafe for ProxyPool
impl Freeze for ProxyPool
impl Send for ProxyPool
impl Sync for ProxyPool
impl Unpin for ProxyPool
impl UnsafeUnpin for ProxyPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more