pub struct MemoryTaskStore { /* private fields */ }Expand description
In-memory TaskStore backed by a HashMap.
This is the default store. Suitable for single-instance deployments. For
horizontal scaling, use an external store that shares state across
instances. Completion wakeups for
wait_for_completion use a per-task
tokio::sync::Notify, which is an implementation detail of this store.
Implementations§
Source§impl MemoryTaskStore
impl MemoryTaskStore
Sourcepub fn cleanup_expired(&self) -> usize
pub fn cleanup_expired(&self) -> usize
Remove expired tasks (call periodically for cleanup).
Returns the number removed. Not part of the TaskStore trait;
external backends typically expire entries natively (e.g. Redis TTL).
Calling this is an optimization, not a correctness requirement: reads already treat an expired task as absent.
Trait Implementations§
Source§impl Clone for MemoryTaskStore
impl Clone for MemoryTaskStore
Source§fn clone(&self) -> MemoryTaskStore
fn clone(&self) -> MemoryTaskStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 MemoryTaskStore
impl Debug for MemoryTaskStore
Source§impl Default for MemoryTaskStore
impl Default for MemoryTaskStore
Source§impl TaskStore for MemoryTaskStore
impl TaskStore for MemoryTaskStore
Source§fn create_task<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
arguments: Value,
ttl: Option<u64>,
owner: TaskOwner,
) -> Pin<Box<dyn Future<Output = Result<(String, CancellationToken)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_task<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
arguments: Value,
ttl: Option<u64>,
owner: TaskOwner,
) -> Pin<Box<dyn Future<Output = Result<(String, CancellationToken)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create and store a new task owned by
owner. Read moreSource§fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get task object by ID. Returns
None if unknown.Source§fn task_owner<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskOwner>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn task_owner<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskOwner>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a task’s owner. Read more
Source§fn get_task_result<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task_result<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a task’s full snapshot (task object, result, error) by ID.
Source§fn wait_for_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn wait_for_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskSnapshot>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Wait for a task to reach a terminal state, then return its snapshot. Read more
Source§fn list_tasks<'life0, 'async_trait>(
&'life0 self,
status_filter: Option<TaskStatus>,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_tasks<'life0, 'async_trait>(
&'life0 self,
status_filter: Option<TaskStatus>,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all tasks, optionally filtered by status.
Source§fn require_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
requests: InputRequests,
message: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn require_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
requests: InputRequests,
message: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Mark a task as requiring input, recording the requests to be answered. Read more
Source§fn outstanding_input_requests<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<InputRequests>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn outstanding_input_requests<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<InputRequests>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read the requests a task is currently waiting on. Read more
Source§fn apply_input_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
responses: InputResponses,
) -> Pin<Box<dyn Future<Output = Result<Option<AppliedInputResponses>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn apply_input_responses<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
responses: InputResponses,
) -> Pin<Box<dyn Future<Output = Result<Option<AppliedInputResponses>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply
tasks/update.inputResponses to a task. Read moreSource§fn set_ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
ttl_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
ttl_ms: u64,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update a task’s time-to-live, measured from creation. Read more
Source§fn complete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
result: CallToolResult,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
result: CallToolResult,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark a task as completed with a result. Read more
Source§fn fail_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
error: JsonRpcError,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fail_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
error: JsonRpcError,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark a task as failed with a structured execution error. Read more
Source§fn cancel_task<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
reason: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cancel_task<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
reason: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<TaskObject>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Cancel a task. Read more
Auto Trait Implementations§
impl Freeze for MemoryTaskStore
impl RefUnwindSafe for MemoryTaskStore
impl Send for MemoryTaskStore
impl Sync for MemoryTaskStore
impl Unpin for MemoryTaskStore
impl UnsafeUnpin for MemoryTaskStore
impl UnwindSafe for MemoryTaskStore
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