Struct WorkerBuilder

Source
pub struct WorkerBuilder<Req, Ctx, 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<M, Serv> WorkerBuilder<(), (), (), M, Serv>

Source

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

👎Deprecated since 0.6.0: Consider using the .backend

Consume a stream directly

Source

pub fn backend<NB: Backend<Request<NJ, Ctx>>, NJ, Res: Send, Ctx>( self, backend: NB, ) -> WorkerBuilder<NJ, Ctx, NB, M, Serv>
where Serv: Service<Request<NJ, Ctx>, Response = Res>,

Set the source to a backend that implements Backend

Source§

impl<Req, M, Serv, Ctx> WorkerBuilder<Req, Ctx, (), M, Serv>

Source

pub fn chain<NewLayer>( self, f: impl FnOnce(ServiceBuilder<M>) -> ServiceBuilder<NewLayer>, ) -> WorkerBuilder<Req, Ctx, (), NewLayer, Serv>

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

Source

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

Allows adding a single layer tower middleware

Source

pub fn data<D>( self, data: D, ) -> WorkerBuilder<Req, Ctx, (), 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, Ctx, Source, Middleware, Serv> Debug for WorkerBuilder<Req, Ctx, Source, Middleware, Serv>

Source§

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

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

impl<Req, P, M, Ctx, Input, Compact, Output, Index> StepWorkerFactory<Ctx, Compact, Input, Output, Index> for WorkerBuilder<Req, Ctx, P, M, StepService<Ctx, Compact, Input, P, Index>>
where Compact: Send + 'static + Sync, P: Backend<Request<StepRequest<Compact, Index>, Ctx>> + 'static + Storage<Job = StepRequest<Compact, Index>> + Clone, M: Layer<StepService<Ctx, Compact, Input, P, Index>> + 'static,

Source§

type Source = P

The request source for the worker
Source§

type Service = <M as Layer<StepService<Ctx, Compact, Input, P, Index>>>::Service

The service that the worker will run jobs against
Source§

type Codec = <P as Backend<Request<StepRequest<Compact, Index>, Ctx>>>::Codec

Represents the codec for the backend bound
Source§

fn build_stepped( self, builder: StepBuilder<Ctx, Compact, Input, Output, Self::Codec, Index>, ) -> Worker<Ready<M::Service, P>>

Builds a StepWorkerFactory using a tower service that can be used to generate a new Worker using the build_stepped method Read more
Source§

impl<Req, P, M, S, Ctx> WorkerFactory<Req, Ctx, S> for WorkerBuilder<Req, Ctx, P, M, S>
where S: Service<Request<Req, Ctx>>, M: Layer<S>, P: Backend<Request<Req, Ctx>>,

Source§

type Source = P

The request source for the worker
Source§

type Service = <M as Layer<S>>::Service

The service that the worker will run jobs against
Source§

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

Builds a WorkerFactory using a tower service that can be used to generate a new Worker using the build method Read more

Auto Trait Implementations§

§

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

§

impl<Req, Ctx, Source, Middleware, Serv> !RefUnwindSafe for WorkerBuilder<Req, Ctx, Source, Middleware, Serv>

§

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

§

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

§

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

§

impl<Req, Ctx, Source, Middleware, Serv> !UnwindSafe for WorkerBuilder<Req, Ctx, Source, Middleware, Serv>

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<Req, W, F, Ctx, FnArgs> WorkerFactoryFn<Req, Ctx, F, FnArgs> for W
where W: WorkerFactory<Req, Ctx, ServiceFn<F, Req, Ctx, FnArgs>>,

Source§

type Source = <W as WorkerFactory<Req, Ctx, ServiceFn<F, Req, Ctx, FnArgs>>>::Source

The request source for the Worker
Source§

type Service = <W as WorkerFactory<Req, Ctx, ServiceFn<F, Req, Ctx, FnArgs>>>::Service

The service that the worker will run jobs against
Source§

fn build_fn( self, f: F, ) -> Worker<Ready<<W as WorkerFactoryFn<Req, Ctx, F, FnArgs>>::Service, <W as WorkerFactoryFn<Req, Ctx, F, FnArgs>>::Source>>

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