Skip to main content

WorkerBuilder

Struct WorkerBuilder 

Source
pub struct WorkerBuilder { /* private fields */ }
Expand description

Staged builder for an immutable queue worker.

Task registration is a local process capability declaration. PostgreSQL remains authoritative for task state and only returns claims whose names match the capabilities frozen into the worker. Producers do not need this registry.

The default concurrency is one and the default finite lease duration is 120 seconds.

Implementations§

Source§

impl WorkerBuilder

Source

pub fn lease_duration(self, lease_duration: Duration) -> Self

Set the finite lease duration for this worker.

PostgreSQL remains authoritative for lease validity and renewal. The duration only controls how much lease time each successful supervision call requests.

Source

pub fn concurrency(self, concurrency: usize) -> Self

Set the maximum number of task attempts this worker executes concurrently.

Claims are limited to currently available execution capacity, so the worker never owns more runs than it can begin executing immediately.

Source

pub fn task<Input, Output>( self, task: Task<Input, Output>, handler: impl TaskHandler<Input, Output>, ) -> Self
where Input: DeserializeOwned + Send + 'static, Output: Serialize + Send + 'static,

Register one typed task with an in-process async handler.

This is the normal registration path. The same Task value is shared by producers and workers, so the persisted name and Rust input/output types stay together without a marker type or runtime registry.

Source

pub fn task_executor<Input, Output>( self, task: Task<Input, Output>, executor: impl TaskExecutor<Input, Output>, ) -> Self
where Input: DeserializeOwned + Send + 'static, Output: Serialize + Send + 'static,

Register one typed task using a reusable TaskExecutor.

The executor may run the attempt in-process or provision a process, container, sandbox, VM, Kubernetes Job, or another execution substrate. This changes only where one attempt computes; durability and supervision still use the same worker path.

Source

pub fn build(self) -> Result<Worker>

Freeze task capabilities and return a runnable worker.

§Errors

Returns an error if registration failed or no task capability was declared.

Trait Implementations§

Source§

impl Debug for WorkerBuilder

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 264 bytes