Skip to main content

load_from_fetcher

Function load_from_fetcher 

Source
pub async fn load_from_fetcher(
    manager: &ProxyManager,
    fetcher: &dyn ProxyFetcher,
) -> ProxyResult<usize>
Expand description

Fetch proxies from fetcher and add them all to manager.

Returns the number of proxies successfully added. Individual add_proxy failures (e.g. duplicate URL) are logged as warnings and do not abort the load.

§Errors

Returns any ProxyError emitted by fetcher.fetch() if the fetcher itself fails.

§Example

use std::sync::Arc;
use stygian_proxy::{ProxyManager, storage::MemoryProxyStore, fetcher::{FreeListFetcher, FreeListSource, load_from_fetcher}};

let manager = ProxyManager::builder()
    .storage(Arc::new(MemoryProxyStore::default()))
    .build()?;
let fetcher = FreeListFetcher::new(vec![FreeListSource::TheSpeedXHttp]);
let n = load_from_fetcher(&manager, &fetcher).await?;
println!("Loaded {n} proxies");