WorkerBuilder

Struct WorkerBuilder 

Source
pub struct WorkerBuilder<Args, Ctx, Source, Middleware> { /* private fields */ }
Expand description

Declaratively builds a Worker

Implementations§

Source§

impl WorkerBuilder<(), (), (), Identity>

Source

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 WorkerBuilder<(), (), (), Identity>

Source

pub fn backend<NB, NJ, Ctx>( self, backend: NB, ) -> WorkerBuilder<NJ, Ctx, NB, Identity>
where NB: Backend<Args = NJ, Context = Ctx>,

Set the source to a backend that implements Backend

Source§

impl<Args, Ctx, M, B> WorkerBuilder<Args, Ctx, B, M>
where B: Backend<Args = Args>,

Source

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

Source

pub fn layer<U>(self, layer: U) -> WorkerBuilder<Args, Ctx, B, Stack<U, M>>

Allows adding middleware to the layer stack

Source

pub fn data<D>(self, data: D) -> WorkerBuilder<Args, Ctx, B, Stack<Data<D>, M>>
where M: Layer<Data<D>>,

Adds data to the context This will be shared by all requests

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

Source

pub fn build<W: IntoWorkerServiceExt<Args, Ctx, Svc, B, M>, Svc>( self, service: W, ) -> Worker<Args, Ctx, B, Svc, M>
where Svc: Service<Task<Args, Ctx, B::IdType>>,

Consumes the builder and a service to construct the final worker

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>,

Source§

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>
where P: Backend<Args = Args, Context = Ctx>, M: Layer<CircuitBreakerLayer>,

Source§

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>>

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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Args, P, M, Ctx> EventListenerExt<Args, Ctx, P, M> for WorkerBuilder<Args, Ctx, P, M>
where P: Backend<Args = Args, Context = Ctx>, M: Layer<EventListenerLayer>,

Source§

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>
where M: Layer<LongRunningLayer>, B: Backend<Args = Args, Context = Ctx>,

Source§

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>>

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>
where P: Backend<Args = Args, Context = Ctx>, M: Layer<ParallelizeLayer<Executor>>,

Source§

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>
where Middleware: Freeze, Source: Freeze,

§

impl<Args, Ctx, Source, Middleware> RefUnwindSafe for WorkerBuilder<Args, Ctx, Source, Middleware>
where Middleware: RefUnwindSafe, Source: RefUnwindSafe, Args: RefUnwindSafe, Ctx: RefUnwindSafe,

§

impl<Args, Ctx, Source, Middleware> Send for WorkerBuilder<Args, Ctx, Source, Middleware>
where Middleware: Send, Source: Send, Args: Send, Ctx: Send,

§

impl<Args, Ctx, Source, Middleware> Sync for WorkerBuilder<Args, Ctx, Source, Middleware>
where Middleware: Sync, Source: Sync, Args: Sync, Ctx: Sync,

§

impl<Args, Ctx, Source, Middleware> Unpin for WorkerBuilder<Args, Ctx, Source, Middleware>
where Middleware: Unpin, Source: Unpin, Args: Unpin, Ctx: Unpin,

§

impl<Args, Ctx, Source, Middleware> UnwindSafe for WorkerBuilder<Args, Ctx, Source, Middleware>
where Middleware: UnwindSafe, Source: UnwindSafe, Args: UnwindSafe, Ctx: UnwindSafe,

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> 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, 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