pub struct Queue { /* private fields */ }Expand description
A task queue.
§Use of key-value store.
The queue uses a namespace handed in during creation. The first element of the scope is “pending” for pending tasks and “running” for running tasks. The second element is the Unix timestamp for when the task is scheduled in milliseconds followed by a dash and the name.
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn create(storage_uri: &Url, namespace: &Ident) -> Result<Self, Error>
pub fn create(storage_uri: &Url, namespace: &Ident) -> Result<Self, Error>
Creates a new queue.
Sourcepub fn pending_tasks_remaining(&self) -> Result<usize, Error>
pub fn pending_tasks_remaining(&self) -> Result<usize, Error>
Returns the number of pending tasks remaining.
Sourcepub fn running_tasks_remaining(&self) -> Result<usize, Error>
pub fn running_tasks_remaining(&self) -> Result<usize, Error>
Returns the number of running tasks.
Sourcepub fn running_tasks_keys(&self) -> Result<Vec<Box<Ident>>, Error>
pub fn running_tasks_keys(&self) -> Result<Vec<Box<Ident>>, Error>
Returns the keys of the currently running tasks
Sourcepub fn schedule_task(
&self,
name: &Ident,
value: &Value,
timestamp_millis: Option<u128>,
mode: ScheduleMode,
) -> Result<(), Error>
pub fn schedule_task( &self, name: &Ident, value: &Value, timestamp_millis: Option<u128>, mode: ScheduleMode, ) -> Result<(), Error>
Schedule a new task.
The task will be scheduled to be run at the given Unix timestamp or,
if the timestamp is None, immediately.
If a task with the same name already exists, then action depends on
the mode.
Sourcepub fn pending_task_scheduled(
&self,
name: &Ident,
) -> Result<Option<u128>, Error>
pub fn pending_task_scheduled( &self, name: &Ident, ) -> Result<Option<u128>, Error>
Returns the scheduled timestamp in ms for the named task, if any.
Sourcepub fn finish_running_task(&self, storage_key: &Ident) -> Result<(), Error>
pub fn finish_running_task(&self, storage_key: &Ident) -> Result<(), Error>
Marks a running task as finished.
Fails if the task is not running.
Sourcepub fn reschedule_running_task(
&self,
storage_key: &Ident,
timestamp_millis: Option<u128>,
) -> Result<(), Error>
pub fn reschedule_running_task( &self, storage_key: &Ident, timestamp_millis: Option<u128>, ) -> Result<(), Error>
Reschedules a running task as pending.
Fails if the task is not running.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Queue
impl RefUnwindSafe for Queue
impl Send for Queue
impl Sync for Queue
impl Unpin for Queue
impl UnsafeUnpin for Queue
impl UnwindSafe for Queue
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more