pub struct WorkerBuilder<Args, Source, Middleware> { /* private fields */ }Expand description
Declaratively builds a Worker
Implementations§
Source§impl WorkerBuilder<(), (), Identity>
impl WorkerBuilder<(), (), Identity>
Sourcepub fn new<T: Into<WorkerContext>>(name: T) -> Self
pub fn new<T: Into<WorkerContext>>(name: T) -> Self
Build a new WorkerBuilder instance with a name for the worker to build
Source§impl WorkerBuilder<(), (), Identity>
impl WorkerBuilder<(), (), Identity>
Sourcepub fn backend<NB, NJ>(self, backend: NB) -> WorkerBuilder<NJ, NB, Identity>where
NB: Backend + BackendConfig<Args = NJ>,
pub fn backend<NB, NJ>(self, backend: NB) -> WorkerBuilder<NJ, NB, Identity>where
NB: Backend + BackendConfig<Args = NJ>,
Set the source to a backend that implements Backend
Source§impl<Args, M, B> WorkerBuilder<Args, B, M>where
B: Backend,
impl<Args, M, B> WorkerBuilder<Args, B, M>where
B: Backend,
Sourcepub fn chain<NewLayer>(
self,
f: impl FnOnce(M) -> NewLayer,
) -> WorkerBuilder<Args, B, NewLayer>
pub fn chain<NewLayer>( self, f: impl FnOnce(M) -> NewLayer, ) -> WorkerBuilder<Args, 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, B, Stack<U, M>>
pub fn layer<U>(self, layer: U) -> WorkerBuilder<Args, B, Stack<U, M>>
Allows adding middleware to the layer stack
Sourcepub fn data<D>(self, data: D) -> WorkerBuilder<Args, B, Stack<Data<D>, M>>
pub fn data<D>(self, data: D) -> WorkerBuilder<Args, B, Stack<Data<D>, M>>
Adds data to the context
This will be shared by all requests
Source§impl<Args, B, M> WorkerBuilder<Args, B, M>
Finalizes the builder and constructs a Worker with the provided service
impl<Args, B, M> WorkerBuilder<Args, B, M>
Finalizes the builder and constructs a Worker with the provided service
Sourcepub fn build<W, Svc, NB>(self, service: W) -> Worker<Args, W::Backend, Svc, M>where
W: IntoWorkerService<B, Svc, Backend = NB>,
B: Backend + BackendConfig,
NB: Backend + BackendConfig + Send + Unpin,
Svc: Service<NB::Task>,
Args: Send + 'static,
pub fn build<W, Svc, NB>(self, service: W) -> Worker<Args, W::Backend, Svc, M>where
W: IntoWorkerService<B, Svc, Backend = NB>,
B: Backend + BackendConfig,
NB: Backend + BackendConfig + Send + Unpin,
Svc: Service<NB::Task>,
Args: Send + 'static,
Consumes the builder and a service to construct the final worker
Trait Implementations§
Source§impl<Args, B, M, Ack, Res> AcknowledgementExt<Args, B, M, Ack, Res> for WorkerBuilder<Args, B, M>
impl<Args, B, M, Ack, Res> AcknowledgementExt<Args, B, M, Ack, Res> for WorkerBuilder<Args, B, M>
Source§fn ack_with(
self,
ack: Ack,
) -> WorkerBuilder<Args, B, Stack<AcknowledgeLayer<Ack>, M>>
fn ack_with( self, ack: Ack, ) -> WorkerBuilder<Args, B, Stack<AcknowledgeLayer<Ack>, M>>
Add an acknowledgment handler to the worker
Source§impl<Args, P, M> CircuitBreaker<Args, P, M> for WorkerBuilder<Args, P, M>
impl<Args, P, M> CircuitBreaker<Args, P, M> for WorkerBuilder<Args, P, M>
Source§fn break_circuit_with(
self,
config: CircuitBreakerConfig,
) -> WorkerBuilder<Args, P, Stack<CircuitBreakerLayer, M>>
fn break_circuit_with( self, config: CircuitBreakerConfig, ) -> WorkerBuilder<Args, 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, Source, Stack<CircuitBreakerLayer, Middleware>>
fn break_circuit( self, ) -> WorkerBuilder<Args, Source, Stack<CircuitBreakerLayer, Middleware>>
Allows the worker to break the circuit in case of failures
Uses default configuration
Source§impl<Args, Source, Middleware> Debug for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> Debug for WorkerBuilder<Args, Source, Middleware>
Source§impl<Args, P, M> EventListenerExt<Args, P, M> for WorkerBuilder<Args, P, M>where
P: Backend,
impl<Args, P, M> EventListenerExt<Args, P, M> for WorkerBuilder<Args, P, M>where
P: Backend,
Source§fn on_event<F: Fn(&WorkerContext, &Event) + Send + Sync + 'static>(
self,
f: F,
) -> WorkerBuilder<Args, P, Stack<EventListenerLayer, M>>
fn on_event<F: Fn(&WorkerContext, &Event) + Send + Sync + 'static>( self, f: F, ) -> WorkerBuilder<Args, P, Stack<EventListenerLayer, M>>
Register a callback for worker events
Source§impl<Args, B, M> LongRunningExt<Args, B, M> for WorkerBuilder<Args, B, M>
impl<Args, B, M> LongRunningExt<Args, B, M> for WorkerBuilder<Args, B, M>
Source§fn long_running_with_cfg(
self,
cfg: LongRunningConfig,
) -> WorkerBuilder<Args, B, Stack<LongRunningLayer, M>>
fn long_running_with_cfg( self, cfg: LongRunningConfig, ) -> WorkerBuilder<Args, B, Stack<LongRunningLayer, M>>
Extension for executing long running jobs with a config
Source§fn long_running(
self,
) -> WorkerBuilder<Args, Source, Stack<LongRunningLayer, Middleware>>
fn long_running( self, ) -> WorkerBuilder<Args, Source, Stack<LongRunningLayer, Middleware>>
Extension for executing long running jobs
Source§impl<Args, P, M, Executor> ParallelizeExt<Args, P, M, Executor> for WorkerBuilder<Args, P, M>
impl<Args, P, M, Executor> ParallelizeExt<Args, P, M, Executor> for WorkerBuilder<Args, P, M>
Source§fn parallelize(
self,
f: Executor,
) -> WorkerBuilder<Args, P, Stack<ParallelizeLayer<Executor>, M>>
fn parallelize( self, f: Executor, ) -> WorkerBuilder<Args, P, Stack<ParallelizeLayer<Executor>, M>>
Register the executor for parallel task execution.
Auto Trait Implementations§
impl<Args, Source, Middleware> !RefUnwindSafe for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> !UnwindSafe for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> Freeze for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> Send for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> Sync for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> Unpin for WorkerBuilder<Args, Source, Middleware>
impl<Args, Source, Middleware> UnsafeUnpin for WorkerBuilder<Args, 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