pub struct InMemoryStorage { /* private fields */ }Expand description
Simple in-memory Storage implementation. Suitable for tests,
single-instance deployments, and as a baseline reference. Holds a
std::sync::Mutex plus a tokio::sync::Notify to park the dequeue
loop until an enqueue notifies it.
Implementations§
Trait Implementations§
Source§impl Debug for InMemoryStorage
impl Debug for InMemoryStorage
Source§impl Default for InMemoryStorage
impl Default for InMemoryStorage
Source§fn default() -> InMemoryStorage
fn default() -> InMemoryStorage
Returns the “default value” for a type. Read more
Source§impl Storage for InMemoryStorage
impl Storage for InMemoryStorage
Source§fn enqueue_task<'life0, 'async_trait>(
&'life0 self,
task: Task,
request_id: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn enqueue_task<'life0, 'async_trait>(
&'life0 self,
task: Task,
request_id: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Push a task onto the back of the work queue.
Source§fn dequeue_task<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<QueuedTask>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn dequeue_task<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<QueuedTask>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pop the next task off the front of the queue, blocking until
one is available (Redis:
BRPOP).fn queue_length<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_queue<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_active_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 Task,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_active_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_active_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 Task,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn store_dead_letter_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 Task,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_dead_letter_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 Task,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Move a task to the dead-letter store (terminal-state archive).
Implementations also remove the task from the active store if
it is present there.
Source§fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Task>> + 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 = Option<Task>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up a task in any store (active first, then dead-letter).
Source§fn put_task<'life0, 'async_trait>(
&'life0 self,
task: Task,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put_task<'life0, 'async_trait>(
&'life0 self,
task: Task,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Upsert a task into the active store, replacing any existing entry
with the same id. Convenience method retained for callers that
don’t want to distinguish create-vs-update.
fn get_task_by_context_and_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
context_id: &'life1 str,
task_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<Task>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn delete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a task from both active and dead-letter stores.
Source§fn list_tasks<'life0, 'async_trait>(
&'life0 self,
filter: TaskFilter,
) -> Pin<Box<dyn Future<Output = Vec<Task>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_tasks<'life0, 'async_trait>(
&'life0 self,
filter: TaskFilter,
) -> Pin<Box<dyn Future<Output = Vec<Task>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List tasks across active + dead-letter, applying
filter.fn list_tasks_by_context<'life0, 'life1, 'async_trait>(
&'life0 self,
context_id: &'life1 str,
filter: TaskFilter,
) -> Pin<Box<dyn Future<Output = Vec<Task>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_contexts<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_contexts_with_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_context<'life0, 'life1, 'async_trait>(
&'life0 self,
context_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_context_and_tasks<'life0, 'life1, 'async_trait>(
&'life0 self,
context_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn cleanup_completed_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_completed_tasks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove every task in dead-letter whose state is
Completed.
Returns the number of tasks deleted.Source§fn cleanup_tasks_with_retention<'life0, 'async_trait>(
&'life0 self,
max_completed: usize,
max_failed: usize,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cleanup_tasks_with_retention<'life0, 'async_trait>(
&'life0 self,
max_completed: usize,
max_failed: usize,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Trim the dead-letter store to at most
max_completed Completed
tasks and max_failed Failed tasks (oldest first). Returns the
total number of tasks deleted.fn get_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageStats> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put_push_notification_config<'life0, 'async_trait>(
&'life0 self,
config: TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_push_notification_config<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<TaskPushNotificationConfig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_push_notification_configs<'life0, 'life1, 'async_trait>(
&'life0 self,
parent: &'life1 str,
) -> Pin<Box<dyn Future<Output = Vec<TaskPushNotificationConfig>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_push_notification_config<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl !Freeze for InMemoryStorage
impl RefUnwindSafe for InMemoryStorage
impl Send for InMemoryStorage
impl Sync for InMemoryStorage
impl Unpin for InMemoryStorage
impl UnsafeUnpin for InMemoryStorage
impl UnwindSafe for InMemoryStorage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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