pub struct TaskQueue {
db: Arc<Database>,
notify: Arc<Notify>,
}Expand description
Pure storage layer for task queue - only handles data persistence
Fields§
§db: Arc<Database>§notify: Arc<Notify>Implementations§
Source§impl TaskQueue
impl TaskQueue
Sourcepub fn insert_pending(
&self,
priority: u64,
task_id: &str,
data: &[u8],
) -> Result<()>
pub fn insert_pending( &self, priority: u64, task_id: &str, data: &[u8], ) -> Result<()>
Insert a task into the pending queue with composite key for uniqueness
Sourcepub fn atomic_pop_pending<F>(&self, on_task: F) -> Result<Option<Task>>
pub fn atomic_pop_pending<F>(&self, on_task: F) -> Result<Option<Task>>
Atomically pop the first pending task and move it to processing Accepts a callback to update task state within the same transaction This prevents race conditions and ensures atomicity of pop→update→save
Sourcepub fn get_first_pending(&self) -> Result<Option<(u64, Vec<u8>)>>
pub fn get_first_pending(&self) -> Result<Option<(u64, Vec<u8>)>>
Get the first pending task without removing it Returns (priority, data) - note: priority extracted from composite key
Sourcepub fn move_to_processing(
&self,
priority: u64,
task_id: &str,
data: &[u8],
) -> Result<()>
pub fn move_to_processing( &self, priority: u64, task_id: &str, data: &[u8], ) -> Result<()>
Move a task from pending to processing (legacy method for tests) Prefer atomic_pop_pending() for production code to avoid race conditions
Sourcepub fn move_to_completed(&self, task_id: &str, data: &[u8]) -> Result<()>
pub fn move_to_completed(&self, task_id: &str, data: &[u8]) -> Result<()>
Move a task from processing to completed
Sourcepub fn get_from_processing(&self, task_id: &str) -> Result<Option<Vec<u8>>>
pub fn get_from_processing(&self, task_id: &str) -> Result<Option<Vec<u8>>>
Get a task from processing table
Sourcepub fn remove_from_processing(&self, task_id: &str) -> Result<()>
pub fn remove_from_processing(&self, task_id: &str) -> Result<()>
Remove a task from processing table
Sourcepub fn get_from_any_table(&self, task_id: &str) -> Result<Option<Vec<u8>>>
pub fn get_from_any_table(&self, task_id: &str) -> Result<Option<Vec<u8>>>
Get a task from any table
Sourcepub async fn wait_for_task(&self)
pub async fn wait_for_task(&self)
Wait for a task to be available
Sourcepub fn notify_task_available(&self)
pub fn notify_task_available(&self)
Notify that a task is available