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
impl WorkerBuilder
Sourcepub fn lease_duration(self, lease_duration: Duration) -> Self
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.
Sourcepub fn concurrency(self, concurrency: usize) -> Self
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.
Sourcepub fn task<Input, Output>(
self,
task: Task<Input, Output>,
handler: impl TaskHandler<Input, Output>,
) -> Self
pub fn task<Input, Output>( self, task: Task<Input, Output>, handler: impl TaskHandler<Input, Output>, ) -> Self
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.
Sourcepub fn task_executor<Input, Output>(
self,
task: Task<Input, Output>,
executor: impl TaskExecutor<Input, Output>,
) -> Self
pub fn task_executor<Input, Output>( self, task: Task<Input, Output>, executor: impl TaskExecutor<Input, Output>, ) -> Self
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WorkerBuilder
impl !UnwindSafe for WorkerBuilder
impl Freeze for WorkerBuilder
impl Send for WorkerBuilder
impl Sync for WorkerBuilder
impl Unpin for WorkerBuilder
impl UnsafeUnpin for WorkerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
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