Struct apalis_core::builder::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: AsRef<str>>(name: T) -> WorkerBuilder<(), (), Identity, Serv>

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: Stream<Item = Result<Option<Request<NJ>>, Error>> + Send + 'static, NJ>( self, stream: NS, ) -> WorkerBuilder<NJ, NS, M, Serv>

Consume a stream directly

source

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

Set the source to a Storage

source

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

Set the source to a MessageQueue

source

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

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

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

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

source§

fn build(self, service: S) -> Worker<Ready<Self::Service, P>>

Build a worker, given a tower service

source§

type Source = P

The request source for the worker
source§

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

source§

fn vzip(self) -> V

source§

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

source§

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

The request source for the Worker
source§

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