pub trait ProxyStoragePort:
Send
+ Sync
+ 'static {
// Required methods
fn add<'life0, 'async_trait>(
&'life0 self,
proxy: Proxy,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn remove<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<ProxyRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update_metrics<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
success: bool,
latency_ms: u64,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_with_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<(ProxyRecord, Arc<ProxyMetrics>)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Abstract storage interface for persisting and querying proxy records.
Implementors must be Send + Sync + 'static to support concurrent access
across async tasks. The trait is object-safe via async_trait.
§Example
use stygian_proxy::storage::ProxyStoragePort;
use stygian_proxy::types::{Proxy, ProxyType};
use uuid::Uuid;
async fn demo(store: &dyn ProxyStoragePort) {
let proxy = Proxy {
url: "http://proxy.example.com:8080".into(),
proxy_type: ProxyType::Http,
username: None,
password: None,
weight: 1,
tags: vec![],
};
let record = store.add(proxy).await.unwrap();
let _ = store.get(record.id).await.unwrap();
}Required Methods§
Sourcefn add<'life0, 'async_trait>(
&'life0 self,
proxy: Proxy,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add<'life0, 'async_trait>(
&'life0 self,
proxy: Proxy,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a new proxy to the store and return its ProxyRecord.
Sourcefn remove<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove a proxy by its UUID. Returns an error if the ID is not found.
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<ProxyRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<ProxyRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return all stored proxy records.
Sourcefn get<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = ProxyResult<ProxyRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch a single proxy record by UUID.
Sourcefn update_metrics<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
success: bool,
latency_ms: u64,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_metrics<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
success: bool,
latency_ms: u64,
) -> Pin<Box<dyn Future<Output = ProxyResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Record the outcome of a request through a proxy.
success: whether the request succeeded.latency_ms: elapsed time in milliseconds.
Sourcefn list_with_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<(ProxyRecord, Arc<ProxyMetrics>)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_with_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ProxyResult<Vec<(ProxyRecord, Arc<ProxyMetrics>)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return all stored proxy records paired with their live metrics reference.
Used by ProxyManager when building
ProxyCandidate slices so that
latency-aware strategies (e.g. least-used) see up-to-date counters.