pub struct ReserveOptions { /* private fields */ }Expand description
Parameters for a reserve call.
Constructed with ReserveOptions::new (which needs the queues to pull
from and the lease duration) and refined with the with_* methods. If you
use a Worker, it builds and manages these for you.
Implementations§
Source§impl ReserveOptions
impl ReserveOptions
Sourcepub fn new(
queues: impl IntoIterator<Item = impl Into<String>>,
lease_duration: Duration,
) -> Result<Self, ReserveOptionsError>
pub fn new( queues: impl IntoIterator<Item = impl Into<String>>, lease_duration: Duration, ) -> Result<Self, ReserveOptionsError>
Begins reserve options for the given queues and lease duration.
Queues are polled in order: index 0 first, then index 1, and so on. The
lease duration is how long a returned job is held before it must be
acked, nacked, or extended. The wait timeout defaults to 30s; override
it with with_wait_timeout.
At least one non-empty queue and a non-zero lease are required.
Sourcepub fn with_wait_timeout(self, wait: Duration) -> Self
pub fn with_wait_timeout(self, wait: Duration) -> Self
Sets how long the server holds the connection open waiting for a job
before returning empty. The server clamps this to its configured
max_wait_timeout.
A zero (or tiny) wait makes the server answer immediately, so a naive
reserve loop turns into a hot loop of back-to-back RPCs — keep a real
wait for polling loops. (Worker rejects a zero wait
outright and backs off on early-empty responses.)
Sourcepub fn wait_timeout(&self) -> Duration
pub fn wait_timeout(&self) -> Duration
Returns the configured long-poll wait timeout.
Sourcepub fn with_worker_id(
self,
id: impl Into<String>,
) -> Result<Self, ReserveOptionsError>
pub fn with_worker_id( self, id: impl Into<String>, ) -> Result<Self, ReserveOptionsError>
Sets a stable worker identifier, recorded server-side for observability. Must be non-empty.
Sourcepub fn with_max_jobs(self, max: u32) -> Self
pub fn with_max_jobs(self, max: u32) -> Self
Sets the maximum number of jobs to return in one response (default 1).
The server clamps this to its
max_reserve_batch. 0 is invalid:
the server rejects it with INVALID_ARGUMENT on every call.
Trait Implementations§
Source§impl Clone for ReserveOptions
impl Clone for ReserveOptions
Source§fn clone(&self) -> ReserveOptions
fn clone(&self) -> ReserveOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReserveOptions
impl Debug for ReserveOptions
Source§impl PartialEq for ReserveOptions
impl PartialEq for ReserveOptions
impl StructuralPartialEq for ReserveOptions
Auto Trait Implementations§
impl Freeze for ReserveOptions
impl RefUnwindSafe for ReserveOptions
impl Send for ReserveOptions
impl Sync for ReserveOptions
impl Unpin for ReserveOptions
impl UnsafeUnpin for ReserveOptions
impl UnwindSafe for ReserveOptions
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request