pub trait QueryTasks {
// Required methods
fn create_task(&self, task: NewTask) -> Result<Task, StorageError>;
fn create_or_ignore_task(&self, task: NewTask) -> Result<(), StorageError>;
fn pull_in_task_deadline(
&self,
target_data_hash: &TaskDataHash,
at_ns: i64,
) -> Result<bool, StorageError>;
fn get_tasks(&self) -> Result<Vec<Task>, StorageError>;
fn get_next_task(&self) -> Result<Option<Task>, StorageError>;
fn upsert_pending_self_remove_task(
&self,
group_id: &GroupId,
task: NewTask,
) -> Result<(), StorageError>;
fn update_task(
&self,
id: i32,
attempts: i32,
last_attempted_at_ns: i64,
next_attempt_at_ns: i64,
) -> Result<Task, StorageError>;
fn delete_task(&self, id: i32) -> Result<bool, StorageError>;
}Required Methods§
fn create_task(&self, task: NewTask) -> Result<Task, StorageError>
Sourcefn create_or_ignore_task(&self, task: NewTask) -> Result<(), StorageError>
fn create_or_ignore_task(&self, task: NewTask) -> Result<(), StorageError>
Idempotent enqueue: a payload-identical duplicate is a no-op (the existing row wins; OR IGNORE swallows any constraint hit, not just data_hash UNIQUE).
Sourcefn pull_in_task_deadline(
&self,
target_data_hash: &TaskDataHash,
at_ns: i64,
) -> Result<bool, StorageError>
fn pull_in_task_deadline( &self, target_data_hash: &TaskDataHash, at_ns: i64, ) -> Result<bool, StorageError>
Lower a task’s next_attempt_at_ns to MIN(current, at_ns) — never raises.
Returns whether a row matched; a missing target is a no-op (false).
TaskWorker dispatch thread only (sole rescheduler).
fn get_tasks(&self) -> Result<Vec<Task>, StorageError>
fn get_next_task(&self) -> Result<Option<Task>, StorageError>
Sourcefn upsert_pending_self_remove_task(
&self,
group_id: &GroupId,
task: NewTask,
) -> Result<(), StorageError>
fn upsert_pending_self_remove_task( &self, group_id: &GroupId, task: NewTask, ) -> Result<(), StorageError>
Ensure exactly one live ProcessPendingSelfRemove task exists for
group_id. Clears only dead rows (expired / attempts-exhausted) then
insert-or-ignores, so a live retrying task keeps its backoff and is never
deleted out from under the TaskRunner, while a stale dead row can’t block
a fresh retry via the data_hash unique constraint.