pub struct TaskStore { /* private fields */ }Expand description
Task store for managing async task execution
Implementations§
Source§impl TaskStore
impl TaskStore
Sourcepub fn new(default_ttl: Duration, default_poll_interval: Duration) -> Self
pub fn new(default_ttl: Duration, default_poll_interval: Duration) -> Self
Create a new task store
Sourcepub fn create_task(
&self,
session_id: &str,
original_request: JsonRpcRequest,
requested_ttl: Option<u64>,
) -> (Task, Receiver<Value>)
pub fn create_task( &self, session_id: &str, original_request: JsonRpcRequest, requested_ttl: Option<u64>, ) -> (Task, Receiver<Value>)
Create a new task
Sourcepub async fn get_task_for_session(
&self,
task_id: &str,
session_id: &str,
) -> Option<Task>
pub async fn get_task_for_session( &self, task_id: &str, session_id: &str, ) -> Option<Task>
Get task for specific session (enforces session isolation)
Sourcepub async fn list_tasks(
&self,
session_id: &str,
cursor: Option<&str>,
limit: usize,
) -> (Vec<Task>, Option<String>)
pub async fn list_tasks( &self, session_id: &str, cursor: Option<&str>, limit: usize, ) -> (Vec<Task>, Option<String>)
List tasks for a session (with pagination)
Sourcepub async fn update_status(
&self,
task_id: &str,
new_status: TaskStatus,
status_message: Option<String>,
) -> Result<(), TaskError>
pub async fn update_status( &self, task_id: &str, new_status: TaskStatus, status_message: Option<String>, ) -> Result<(), TaskError>
Update task status
Sourcepub async fn store_result(
&self,
task_id: &str,
result: Value,
) -> Result<(), TaskError>
pub async fn store_result( &self, task_id: &str, result: Value, ) -> Result<(), TaskError>
Store task result
Sourcepub async fn get_result(&self, task_id: &str) -> Option<Value>
pub async fn get_result(&self, task_id: &str) -> Option<Value>
Get stored result
Sourcepub async fn wait_for_result(
&self,
task_id: &str,
timeout: Duration,
) -> Result<Value, TaskError>
pub async fn wait_for_result( &self, task_id: &str, timeout: Duration, ) -> Result<Value, TaskError>
Wait for task result (blocks until terminal state)
Sourcepub async fn cancel_task(
&self,
task_id: &str,
session_id: &str,
) -> Result<Task, TaskError>
pub async fn cancel_task( &self, task_id: &str, session_id: &str, ) -> Result<Task, TaskError>
Cancel a task
Sourcepub async fn cleanup_expired(&self)
pub async fn cleanup_expired(&self)
Cleanup expired tasks (should be called periodically)
Sourcepub fn spawn_cleanup_task(self: Arc<Self>, interval: Duration)
pub fn spawn_cleanup_task(self: Arc<Self>, interval: Duration)
Spawn background cleanup task
Auto Trait Implementations§
impl Freeze for TaskStore
impl !RefUnwindSafe for TaskStore
impl Send for TaskStore
impl Sync for TaskStore
impl Unpin for TaskStore
impl !UnwindSafe for TaskStore
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