pub struct WorkerBuilder<Args, Ctx, Source, Middleware> { /* private fields */ }Expand description
Declaratively builds a Worker
Implementations§
Source§impl WorkerBuilder<(), (), (), Identity>
impl WorkerBuilder<(), (), (), Identity>
Sourcepub fn new<T: AsRef<str>>(name: T) -> WorkerBuilder<(), (), (), Identity>
pub fn new<T: AsRef<str>>(name: T) -> WorkerBuilder<(), (), (), Identity>
Build a new WorkerBuilder instance with a name for the worker to build
Source§impl<Args, Ctx, M, B> WorkerBuilder<Args, Ctx, B, M>where
B: Backend<Args = Args>,
impl<Args, Ctx, M, B> WorkerBuilder<Args, Ctx, B, M>where
B: Backend<Args = Args>,
Sourcepub fn chain<NewLayer>(
self,
f: impl FnOnce(M) -> NewLayer,
) -> WorkerBuilder<Args, Ctx, B, NewLayer>
pub fn chain<NewLayer>( self, f: impl FnOnce(M) -> NewLayer, ) -> WorkerBuilder<Args, Ctx, B, NewLayer>
Allows of decorating the service that consumes jobs. Allows adding multiple middleware in one call
Sourcepub fn layer<U>(self, layer: U) -> WorkerBuilder<Args, Ctx, B, Stack<U, M>>
pub fn layer<U>(self, layer: U) -> WorkerBuilder<Args, Ctx, B, Stack<U, M>>
Allows adding middleware to the layer stack
Source§impl<Args, Ctx, B, M> WorkerBuilder<Args, Ctx, B, M>where
B: Backend<Args = Args, Context = Ctx>,
Finalizes the builder and constructs a Worker with the provided service
impl<Args, Ctx, B, M> WorkerBuilder<Args, Ctx, B, M>where
B: Backend<Args = Args, Context = Ctx>,
Finalizes the builder and constructs a Worker with the provided service
Trait Implementations§
Source§impl<Args, B, M, Ctx, Ack, Res> AcknowledgementExt<Args, Ctx, B, M, Ack, Res> for WorkerBuilder<Args, Ctx, B, M>where
M: Layer<AcknowledgeLayer<Ack>>,
Ack: Acknowledge<Res, Ctx, B::IdType>,
B: Backend<Args = Args, Context = Ctx>,
impl<Args, B, M, Ctx, Ack, Res> AcknowledgementExt<Args, Ctx, B, M, Ack, Res> for WorkerBuilder<Args, Ctx, B, M>where
M: Layer<AcknowledgeLayer<Ack>>,
Ack: Acknowledge<Res, Ctx, B::IdType>,
B: Backend<Args = Args, Context = Ctx>,
Source§fn ack_with(
self,
ack: Ack,
) -> WorkerBuilder<Args, Ctx, B, Stack<AcknowledgeLayer<Ack>, M>>
fn ack_with( self, ack: Ack, ) -> WorkerBuilder<Args, Ctx, B, Stack<AcknowledgeLayer<Ack>, M>>
Add an acknowledgment handler to the worker
Source§impl<Args, P, M, Ctx> CircuitBreaker<Args, Ctx, P, M> for WorkerBuilder<Args, Ctx, P, M>
impl<Args, P, M, Ctx> CircuitBreaker<Args, Ctx, P, M> for WorkerBuilder<Args, Ctx, P, M>
Source§fn break_circuit_with(
self,
config: CircuitBreakerConfig,
) -> WorkerBuilder<Args, Ctx, P, Stack<CircuitBreakerLayer, M>>
fn break_circuit_with( self, config: CircuitBreakerConfig, ) -> WorkerBuilder<Args, Ctx, P, Stack<CircuitBreakerLayer, M>>
Allows the worker to break the circuit w in case of failures
Allows customizing the CircuitBreakerConfig
Source§fn break_circuit(
self,
) -> WorkerBuilder<Args, Ctx, Source, Stack<CircuitBreakerLayer, Middleware>>
fn break_circuit( self, ) -> WorkerBuilder<Args, Ctx, Source, Stack<CircuitBreakerLayer, Middleware>>
Allows the worker to break the circuit in case of failures
Uses default configuration
Source§impl<Args, Ctx, Source, Middleware> Debug for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> Debug for WorkerBuilder<Args, Ctx, Source, Middleware>
Source§impl<Args, P, M, Ctx> EventListenerExt<Args, Ctx, P, M> for WorkerBuilder<Args, Ctx, P, M>
impl<Args, P, M, Ctx> EventListenerExt<Args, Ctx, P, M> for WorkerBuilder<Args, Ctx, P, M>
Source§fn on_event<F: Fn(&WorkerContext, &Event) + Send + Sync + 'static>(
self,
f: F,
) -> WorkerBuilder<Args, Ctx, P, Stack<EventListenerLayer, M>>
fn on_event<F: Fn(&WorkerContext, &Event) + Send + Sync + 'static>( self, f: F, ) -> WorkerBuilder<Args, Ctx, P, Stack<EventListenerLayer, M>>
Register a callback for worker events
Source§impl<Args, B, M, Ctx> LongRunningExt<Args, Ctx, B, M> for WorkerBuilder<Args, Ctx, B, M>
impl<Args, B, M, Ctx> LongRunningExt<Args, Ctx, B, M> for WorkerBuilder<Args, Ctx, B, M>
Source§fn long_running_with_cfg(
self,
cfg: LongRunningConfig,
) -> WorkerBuilder<Args, Ctx, B, Stack<LongRunningLayer, M>>
fn long_running_with_cfg( self, cfg: LongRunningConfig, ) -> WorkerBuilder<Args, Ctx, B, Stack<LongRunningLayer, M>>
Extension for executing long running jobs with a config
Source§fn long_running(
self,
) -> WorkerBuilder<Args, Ctx, Source, Stack<LongRunningLayer, Middleware>>
fn long_running( self, ) -> WorkerBuilder<Args, Ctx, Source, Stack<LongRunningLayer, Middleware>>
Extension for executing long running jobs
Source§impl<Args, P, M, Ctx, Executor> ParallelizeExt<Args, Ctx, P, M, Executor> for WorkerBuilder<Args, Ctx, P, M>
impl<Args, P, M, Ctx, Executor> ParallelizeExt<Args, Ctx, P, M, Executor> for WorkerBuilder<Args, Ctx, P, M>
Source§fn parallelize(
self,
f: Executor,
) -> WorkerBuilder<Args, Ctx, P, Stack<ParallelizeLayer<Executor>, M>>
fn parallelize( self, f: Executor, ) -> WorkerBuilder<Args, Ctx, P, Stack<ParallelizeLayer<Executor>, M>>
Register the executor for parallel task execution.
Auto Trait Implementations§
impl<Args, Ctx, Source, Middleware> Freeze for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> RefUnwindSafe for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> Send for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> Sync for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> Unpin for WorkerBuilder<Args, Ctx, Source, Middleware>
impl<Args, Ctx, Source, Middleware> UnwindSafe for WorkerBuilder<Args, Ctx, Source, Middleware>
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
Mutably borrows from an owned value. Read more