Expand description
A small, thread-safe, in-memory task queue.
taskq assigns every submitted task a queue-local TaskId. Submitting a
task with an optional TaskKey additionally enables idempotency: the same
key cannot be submitted again while its task is still tracked by the queue.
Consumers can either poll with SimpleTaskQueue::try_pop_task or wait
asynchronously with SimpleTaskQueue::pop_task.
§Example
use taskq::{SimpleTaskQueue, TaskState};
let queue = SimpleTaskQueue::<&str>::new();
let task_id = queue.submit_task("send email")?;
let task = queue.try_pop_task().expect("a task should be queued");
assert_eq!(task.id(), task_id);
assert_eq!(task.payload(), &"send email");
queue.mark_task_success(task.id())?;
assert_eq!(queue.get_task_status(task_id)?.state(), TaskState::Success);Structs§
- Simple
Task Queue - A bounded, thread-safe, in-memory task queue.
- Task
- A task received from a queue.
- Task
Status - A snapshot of a task’s lifecycle state and timestamps.
Enums§
Traits§
- Task
Queue - Common operations implemented by a task queue.
Functions§
- is_
finished - Returns whether a task state is terminal.