pub struct MemoryProxyStore { /* private fields */ }Expand description
In-memory implementation of ProxyStoragePort.
Uses a tokio::sync::RwLock-guarded HashMap for thread-safe access.
Metrics are updated via atomic operations, so only a read lock is
needed for update_metrics calls —
write contention stays low even under heavy concurrent load.
§Example
use stygian_proxy::storage::{MemoryProxyStore, ProxyStoragePort};
use stygian_proxy::types::{Proxy, ProxyType};
let store = MemoryProxyStore::default();
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();
assert_eq!(store.list().await.unwrap().len(), 1);
store.remove(record.id).await.unwrap();
assert!(store.list().await.unwrap().is_empty());Implementations§
Source§impl MemoryProxyStore
impl MemoryProxyStore
Sourcepub async fn with_proxies(proxies: Vec<Proxy>) -> ProxyResult<Self>
pub async fn with_proxies(proxies: Vec<Proxy>) -> ProxyResult<Self>
Build a store pre-populated with proxies, validating each URL.
Returns an error on the first invalid URL encountered.
Trait Implementations§
Source§impl Clone for MemoryProxyStore
impl Clone for MemoryProxyStore
Source§fn clone(&self) -> MemoryProxyStore
fn clone(&self) -> MemoryProxyStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MemoryProxyStore
impl Debug for MemoryProxyStore
Source§impl Default for MemoryProxyStore
impl Default for MemoryProxyStore
Source§fn default() -> MemoryProxyStore
fn default() -> MemoryProxyStore
Returns the “default value” for a type. Read more
Source§impl ProxyStoragePort for MemoryProxyStore
impl ProxyStoragePort for MemoryProxyStore
Source§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 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.Source§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 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.
Source§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 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.
Source§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 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.
Source§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,
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. Read more
Auto Trait Implementations§
impl Freeze for MemoryProxyStore
impl !RefUnwindSafe for MemoryProxyStore
impl Send for MemoryProxyStore
impl Sync for MemoryProxyStore
impl Unpin for MemoryProxyStore
impl UnsafeUnpin for MemoryProxyStore
impl !UnwindSafe for MemoryProxyStore
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