pub struct InMemoryTaskStore { /* private fields */ }Expand description
In-memory TaskStore backed by a HashMap under a RwLock.
Suitable for testing and single-process deployments. Data is lost when the process exits.
Supports TTL-based eviction of terminal tasks and a maximum capacity limit to prevent unbounded memory growth.
§Eviction behavior
Eviction runs automatically every 64 writes (EVICTION_INTERVAL) and
whenever the store exceeds max_capacity. However, if the system goes
idle (no save() calls), completed tasks may persist in memory longer
than their TTL.
Operators should call run_eviction() periodically
(e.g. every 60 seconds via tokio::time::interval) to ensure timely
cleanup of terminal tasks during idle periods.
Implementations§
Source§impl InMemoryTaskStore
impl InMemoryTaskStore
Sourcepub fn new() -> InMemoryTaskStore
pub fn new() -> InMemoryTaskStore
Creates a new empty in-memory task store with default configuration.
Default: max 10,000 tasks, 1-hour TTL for terminal tasks.
Sourcepub fn with_config(config: TaskStoreConfig) -> InMemoryTaskStore
pub fn with_config(config: TaskStoreConfig) -> InMemoryTaskStore
Creates a new in-memory task store with custom configuration.
Sourcepub async fn run_eviction(&self)
pub async fn run_eviction(&self)
Runs background eviction of expired and over-capacity entries.
Call this periodically (e.g. every 60 seconds) to clean up terminal
tasks that would otherwise persist until the next save() call.
Trait Implementations§
Source§impl Debug for InMemoryTaskStore
impl Debug for InMemoryTaskStore
Source§impl Default for InMemoryTaskStore
impl Default for InMemoryTaskStore
Source§fn default() -> InMemoryTaskStore
fn default() -> InMemoryTaskStore
Source§impl TaskStore for InMemoryTaskStore
impl TaskStore for InMemoryTaskStore
Source§fn save<'a>(
&'a self,
task: Task,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn save<'a>( &'a self, task: Task, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Source§fn get<'a>(
&'a self,
id: &'a TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>, A2aError>> + Send + 'a>>
fn get<'a>( &'a self, id: &'a TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<Task>, A2aError>> + Send + 'a>>
None if not found. Read more