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>
获取代理,支持负载均衡和故障转移
Sourcepub async fn get_best_tunnel(&self) -> Option<ProxyEnum>
pub async fn get_best_tunnel(&self) -> Option<ProxyEnum>
获取质量最好的隧道代理
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<()>
报告代理使用结果
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<()>
报告代理成功使用
Sourcepub async fn report_failure(&self, proxy: &ProxyEnum) -> Result<()>
pub async fn report_failure(&self, proxy: &ProxyEnum) -> Result<()>
报告代理失败使用
Sourcepub async fn get_pool_status(&self) -> HashMap<String, usize>
pub async fn get_pool_status(&self) -> HashMap<String, usize>
获取池状态
Sourcepub async fn health_check(&self) -> Result<()>
pub async fn health_check(&self) -> Result<()>
执行健康检查
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