Struct apalis::prelude::WorkerBuilder

source ·
pub struct WorkerBuilder<Req, Source, Middleware, Serv> { /* private fields */ }
Expand description

Allows building a Worker. Usually the output is Worker<Ready>

Implementations§

source§

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

source

pub fn new<T>(name: T) -> WorkerBuilder<(), (), Identity, Serv>
where T: AsRef<str>,

Build a new WorkerBuilder instance with a name for the worker to build

source§

impl<J, S, M, Serv> WorkerBuilder<J, S, M, Serv>

source

pub fn stream<NS, NJ>(self, stream: NS) -> WorkerBuilder<NJ, NS, M, Serv>
where NS: Stream<Item = Result<Option<Request<NJ>>, Error>> + Send + 'static,

Consume a stream directly

source

pub fn with_storage<NS, NJ>(self, storage: NS) -> WorkerBuilder<NJ, NS, M, Serv>
where NS: Storage<Job = NJ>,

Set the source to a Storage

source

pub fn with_mq<NS, NJ>( self, message_queue: NS ) -> WorkerBuilder<NJ, NS, M, Serv>
where NS: MessageQueue<NJ>,

Set the source to a MessageQueue

source

pub fn source<NS, NJ>(self, backend: NS) -> WorkerBuilder<NJ, NS, M, Serv>
where NS: Backend<Request<NJ>>,

Set the source to a generic backend that implements only Backend

source§

impl<Request, Stream, M, Serv> WorkerBuilder<Request, Stream, M, Serv>

source

pub fn chain<NewLayer>( self, f: impl Fn(ServiceBuilder<M>) -> ServiceBuilder<NewLayer> ) -> WorkerBuilder<Request, Stream, NewLayer, Serv>

Allows of decorating the service that consumes jobs. Allows adding multiple tower middleware

source

pub fn layer<U>( self, layer: U ) -> WorkerBuilder<Request, Stream, Stack<U, M>, Serv>
where M: Layer<U>,

Allows adding a single layer tower middleware

source

pub fn data<D>( self, data: D ) -> WorkerBuilder<Request, Stream, Stack<Data<D>, M>, Serv>
where M: Layer<Data<D>>,

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

Trait Implementations§

source§

impl<Req, Source, Middleware, Serv> Debug for WorkerBuilder<Req, Source, Middleware, Serv>

source§

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

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

impl<Req, P, M, S> WorkerFactory<Req, S> for WorkerBuilder<Req, P, M, S>
where Req: Send + 'static + Sync, P: Backend<Request<Req>> + 'static, M: 'static + Layer<<<P as Backend<Request<Req>>>::Layer as Layer<S>>::Service>, S: Service<Request<Req>> + Send + 'static + Clone + Sync, <S as Service<Request<Req>>>::Future: Send, <S as Service<Request<Req>>>::Response: 'static, <P as Backend<Request<Req>>>::Layer: Layer<S>,

source§

fn build( self, service: S ) -> Worker<Ready<<WorkerBuilder<Req, P, M, S> as WorkerFactory<Req, S>>::Service, P>>

Build a worker, given a tower service

§

type Source = P

The request source for the worker
§

type Service = <M as Layer<<<P as Backend<Request<Req>>>::Layer as Layer<S>>::Service>>::Service

The service that the worker will run jobs against

Auto Trait Implementations§

§

impl<Req, Source, Middleware, Serv> Freeze for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: Freeze, Middleware: Freeze,

§

impl<Req, Source, Middleware, Serv> RefUnwindSafe for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: RefUnwindSafe, Req: RefUnwindSafe, Middleware: RefUnwindSafe, Serv: RefUnwindSafe,

§

impl<Req, Source, Middleware, Serv> Send for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: Send, Req: Send, Middleware: Send, Serv: Send,

§

impl<Req, Source, Middleware, Serv> Sync for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: Sync, Req: Sync, Middleware: Sync, Serv: Sync,

§

impl<Req, Source, Middleware, Serv> Unpin for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: Unpin, Req: Unpin, Middleware: Unpin, Serv: Unpin,

§

impl<Req, Source, Middleware, Serv> UnwindSafe for WorkerBuilder<Req, Source, Middleware, Serv>
where Source: UnwindSafe, Req: UnwindSafe, Middleware: UnwindSafe, Serv: 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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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

impl<J, W, F, K> WorkerFactoryFn<J, F, K> for W
where W: WorkerFactory<J, ServiceFn<F, K>>,

§

type Source = <W as WorkerFactory<J, ServiceFn<F, K>>>::Source

The request source for the Worker
§

type Service = <W as WorkerFactory<J, ServiceFn<F, K>>>::Service

The service that the worker will run jobs against
source§

fn build_fn( self, f: F ) -> Worker<Ready<<W as WorkerFactoryFn<J, F, K>>::Service, <W as WorkerFactoryFn<J, F, K>>::Source>>

Builds a WorkerFactoryFn using ServiceFn that can be used to generate new Worker using the build_fn method Read more