Skip to main content

WorkQueue

Struct WorkQueue 

Source
pub struct WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,
{ /* private fields */ }

Implementations§

Source§

impl<M> WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source

pub fn new(job_name: String, backend: Arc<dyn Backend>) -> WorkQueue<M>

Source

pub fn queue_name(&self) -> &str

Get the queue name (used as prefix for all queue keys)

Source

pub fn start_with_name( name: String, backend: Arc<dyn Backend + Send + Sync>, ) -> ActorRef<WorkQueue<M>>

Source

pub fn run_with_config( &self, job: Job<M>, config: EnqueueConfig, ) -> Result<(), Error>

Source

pub fn enqueue(&self, job: Job<M>) -> Result<(), Error>

Source

pub fn re_enqueue(&self, job: Job<M>) -> Result<(), Error>

Source

pub fn mark_job_is_canceled(&self, job_id: &str)

Source

pub fn mark_job_is_finished(&self, job: Job<M>) -> Result<(), Error>

Source

pub fn mark_job_is_failed(&self, job: Job<M>) -> Result<(), Error>

Source

pub fn process_jobs(&self)

Source

pub fn pick_jobs_to_process(&self) -> Result<Vec<Job<M>>, Error>

Source

pub fn execute_job_task(&self, job: Job<M>)

Source

pub async fn execute_job(&self, job: Job<M>) -> Result<(), Error>

Source

pub fn cancel_job(&self, job_id: &str) -> Result<(), Error>

Source

pub fn get_job(&self, job_id: &str) -> Result<Option<Job<M>>, Error>

Source

pub fn retry_job(&self, job_id: &str) -> Result<bool, Error>

Source

pub fn read_job(&self, job_id: &str) -> Result<Option<Job<M>>, Error>

Source

pub fn get_processing_job_ids( &self, _count: usize, ) -> Result<Vec<String>, Error>

Trait Implementations§

Source§

impl<M> Actor for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Mailbox = UnboundedMailbox<WorkQueue<M>>

The mailbox type used for the actor. Read more
Source§

fn name() -> &'static str

The name of the actor, which can be useful for logging or debugging. Read more
Source§

fn new_mailbox() -> (<WorkQueue<M> as Actor>::Mailbox, <<WorkQueue<M> as Actor>::Mailbox as Mailbox<WorkQueue<M>>>::Receiver)

Creates a new mailbox for the actor. This sets up the message queue and receiver for the actor. Read more
Source§

fn on_start( &mut self, actor_ref: ActorRef<Self>, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send

Called when the actor starts, before it processes any messages. Read more
Source§

fn on_panic( &mut self, actor_ref: WeakActorRef<Self>, err: PanicError, ) -> impl Future<Output = Result<Option<ActorStopReason>, Box<dyn Error + Send + Sync>>> + Send

Called when the actor encounters a panic or an error during “tell” message handling. Read more
Called when a linked actor dies. Read more
Source§

fn on_stop( &mut self, actor_ref: WeakActorRef<Self>, reason: ActorStopReason, ) -> impl Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send

Called before the actor stops. Read more
Source§

impl<M> Clone for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

fn clone(&self) -> WorkQueue<M>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M> Message<CancelJob> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = Result<(), Error>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: CancelJob, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<CancelJob>>::Reply>, ) -> <WorkQueue<M> as Message<CancelJob>>::Reply

Handler for this message.
Source§

impl<M> Message<Enqueue<M>> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = Result<(), Error>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: Enqueue<M>, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<Enqueue<M>>>::Reply>, ) -> <WorkQueue<M> as Message<Enqueue<M>>>::Reply

Handler for this message.
Source§

impl<M> Message<GetJob<M>> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = Option<Job<M>>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: GetJob<M>, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<GetJob<M>>>::Reply>, ) -> <WorkQueue<M> as Message<GetJob<M>>>::Reply

Handler for this message.
Source§

impl<M> Message<ProcessTick> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = ()

The reply sent back to the message caller.
Source§

async fn handle( &mut self, _msg: ProcessTick, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<ProcessTick>>::Reply>, ) -> <WorkQueue<M> as Message<ProcessTick>>::Reply

Handler for this message.
Source§

impl<M> Message<RetryJob<M>> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = Result<bool, Error>

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: RetryJob<M>, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<RetryJob<M>>>::Reply>, ) -> <WorkQueue<M> as Message<RetryJob<M>>>::Reply

Handler for this message.
Source§

impl<M> Message<UpdateWorkQueue> for WorkQueue<M>
where M: Executable + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,

Source§

type Reply = ()

The reply sent back to the message caller.
Source§

async fn handle( &mut self, msg: UpdateWorkQueue, _ctx: Context<'_, WorkQueue<M>, <WorkQueue<M> as Message<UpdateWorkQueue>>::Reply>, ) -> <WorkQueue<M> as Message<UpdateWorkQueue>>::Reply

Handler for this message.

Auto Trait Implementations§

§

impl<M> Freeze for WorkQueue<M>

§

impl<M> !RefUnwindSafe for WorkQueue<M>

§

impl<M> Send for WorkQueue<M>

§

impl<M> Sync for WorkQueue<M>

§

impl<M> Unpin for WorkQueue<M>
where M: Unpin,

§

impl<M> !UnwindSafe for WorkQueue<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<A, T> DynMessage<A> for T
where A: Actor + Message<T>, T: Send + 'static,

Source§

fn handle_dyn( self: Box<T>, state: &mut A, actor_ref: ActorRef<A>, tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>, ) -> Pin<Box<dyn Future<Output = Option<Box<dyn Debug + Send>>> + Send + '_>>

Handles the dyn message with the provided actor state, ref, and reply sender.
Source§

fn as_any(self: Box<T>) -> Box<dyn Any>

Casts the type to a Box<dyn Any>.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more