pub struct PooledAsyncBackend { /* private fields */ }Expand description
Pooled async storage backend with resource management
This backend wraps AsyncSledBackend with a semaphore-based pool that:
- Limits concurrent operations to prevent resource exhaustion
- Provides backpressure when the pool is saturated
- Collects metrics on pool utilization
- Implements timeouts to prevent indefinite blocking
§Examples
use llm_memory_graph::storage::{PooledAsyncBackend, PoolConfig};
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = PoolConfig::new()
.with_max_concurrent(50)
.with_timeout(3000);
let backend = PooledAsyncBackend::open(Path::new("./data/db"), config).await?;
// Get pool metrics
let metrics = backend.metrics();
println!("Active operations: {}", metrics.active_operations);
Ok(())
}Implementations§
Source§impl PooledAsyncBackend
impl PooledAsyncBackend
Sourcepub async fn open(path: &Path, config: PoolConfig) -> Result<Self>
pub async fn open(path: &Path, config: PoolConfig) -> Result<Self>
Open a pooled async backend
§Examples
use llm_memory_graph::storage::{PooledAsyncBackend, PoolConfig};
use std::path::Path;
let backend = PooledAsyncBackend::open(
Path::new("./data/db"),
PoolConfig::default()
).await?;Sourcepub fn metrics(&self) -> PoolMetricsSnapshot
pub fn metrics(&self) -> PoolMetricsSnapshot
Get current pool metrics
Sourcepub fn config(&self) -> &PoolConfig
pub fn config(&self) -> &PoolConfig
Get pool configuration
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Get number of available permits
Trait Implementations§
Source§impl AsyncStorageBackend for PooledAsyncBackend
impl AsyncStorageBackend for PooledAsyncBackend
Source§fn store_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 Node,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_node<'life0, 'life1, 'async_trait>(
&'life0 self,
node: &'life1 Node,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store a node in the backend asynchronously
Source§fn get_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Option<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Option<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a node by ID asynchronously
Source§fn delete_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a node asynchronously
Source§fn store_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
edge: &'life1 Edge,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
edge: &'life1 Edge,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store an edge asynchronously
Source§fn get_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EdgeId,
) -> Pin<Box<dyn Future<Output = Result<Option<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EdgeId,
) -> Pin<Box<dyn Future<Output = Result<Option<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve an edge by ID asynchronously
Source§fn delete_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EdgeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_edge<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EdgeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete an edge asynchronously
Source§fn get_session_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Node>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all nodes in a session asynchronously
Source§fn get_outgoing_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
node_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_outgoing_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
node_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all edges from a node asynchronously
Source§fn get_incoming_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
node_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_incoming_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
node_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Edge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all edges to a node asynchronously
Source§fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush any pending writes asynchronously
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StorageStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StorageStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get storage statistics asynchronously
Source§fn store_nodes_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
nodes: &'life1 [Node],
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_nodes_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
nodes: &'life1 [Node],
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Batch store multiple nodes asynchronously for improved performance
Source§fn store_edges_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
edges: &'life1 [Edge],
) -> Pin<Box<dyn Future<Output = Result<Vec<EdgeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_edges_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
edges: &'life1 [Edge],
) -> Pin<Box<dyn Future<Output = Result<Vec<EdgeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Batch store multiple edges asynchronously for improved performance
Source§fn get_session_nodes_stream(
&self,
session_id: &SessionId,
) -> Pin<Box<dyn Stream<Item = Result<Node>> + Send + '_>>
fn get_session_nodes_stream( &self, session_id: &SessionId, ) -> Pin<Box<dyn Stream<Item = Result<Node>> + Send + '_>>
Stream nodes from a session for memory-efficient iteration over large result sets Read more
Source§fn count_session_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_session_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Count nodes in a session without loading them into memory Read more
Auto Trait Implementations§
impl Freeze for PooledAsyncBackend
impl !RefUnwindSafe for PooledAsyncBackend
impl Send for PooledAsyncBackend
impl Sync for PooledAsyncBackend
impl Unpin for PooledAsyncBackend
impl !UnwindSafe for PooledAsyncBackend
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