pub struct EnqueueRequest { /* private fields */ }Expand description
A job to enqueue, built fluently.
Start with EnqueueRequest::new (which requires a queue and a job type)
and layer on the optional fields with the with_* methods. Pass the result
to SeppClient::enqueue,
enqueue_batch, or
enqueue_atomic.
use sepp_rs::{EnqueueRequest, Payload, Priority};
let req = EnqueueRequest::new("emails", "send_welcome")?
.with_payload(Payload::new(b"{}".to_vec(), "application/json"))
.with_priority(Priority::P7)
.with_idempotency_key("welcome-user-42")
.with_max_attempts(5);Fields left unset fall back to the queue’s configured defaults on the server.
Implementations§
Source§impl EnqueueRequest
impl EnqueueRequest
Sourcepub fn new(
queue: impl Into<String>,
job_type: impl Into<String>,
) -> Result<Self, EnqueueRequestBuilderError>
pub fn new( queue: impl Into<String>, job_type: impl Into<String>, ) -> Result<Self, EnqueueRequestBuilderError>
Begins a request for the given queue and job type.
Both must be non-empty, or EnqueueRequestBuilderError is returned.
Sourcepub fn with_payload(self, payload: Payload) -> Self
pub fn with_payload(self, payload: Payload) -> Self
Sets the job’s payload. Its data and encoding must be non-empty —
leave the payload unset for jobs that carry no data (see Payload).
Sourcepub fn with_idempotency_key(self, key: impl Into<String>) -> Self
pub fn with_idempotency_key(self, key: impl Into<String>) -> Self
Sets a deduplication key. The server drops a duplicate enqueue with the
same key within the queue’s dedup window, returning the existing job’s
id with EnqueueAck::deduplicated set.
Sourcepub fn with_priority(self, priority: Priority) -> Self
pub fn with_priority(self, priority: Priority) -> Self
Overrides the queue’s default Priority.
Sourcepub fn with_max_attempts(self, attempts: u32) -> Self
pub fn with_max_attempts(self, attempts: u32) -> Self
Overrides the queue’s default maximum delivery attempts before the job is dead-lettered.
Sourcepub fn with_custom(self, custom: HashMap<String, Primitive>) -> Self
pub fn with_custom(self, custom: HashMap<String, Primitive>) -> Self
Replaces the custom metadata map wholesale. See
with_custom_entry to add one key at a time.
Sourcepub fn with_custom_entry(
self,
key: impl Into<String>,
value: impl Into<Primitive>,
) -> Self
pub fn with_custom_entry( self, key: impl Into<String>, value: impl Into<Primitive>, ) -> Self
Inserts a single custom metadata entry. Any type that converts into a
Primitive (&str, i64, bool, …) is accepted as the value.
Sourcepub fn with_trace_context(self, trace_context: TraceContext) -> Self
pub fn with_trace_context(self, trace_context: TraceContext) -> Self
Attaches a TraceContext to the job.
With the opentelemetry feature, the current span’s context is injected
automatically at enqueue time, so set this only to override that or to
propagate a trace captured elsewhere.
Sourcepub fn with_scheduled_at(self, scheduled_at: SystemTime) -> Self
pub fn with_scheduled_at(self, scheduled_at: SystemTime) -> Self
Delays the job until the given time. The job is not delivered to any
worker before then. Must be within the server’s
max_schedule_horizon, or the
job is rejected with JobRejection::ScheduledTooFar.
Trait Implementations§
Source§impl Clone for EnqueueRequest
impl Clone for EnqueueRequest
Source§fn clone(&self) -> EnqueueRequest
fn clone(&self) -> EnqueueRequest
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 EnqueueRequest
impl Debug for EnqueueRequest
Source§impl From<&DeadLetterRecord> for EnqueueRequest
impl From<&DeadLetterRecord> for EnqueueRequest
Source§fn from(r: &DeadLetterRecord) -> Self
fn from(r: &DeadLetterRecord) -> Self
Replays a dead-lettered job into its original queue, leaving the record intact.
Source§impl From<DeadLetterRecord> for EnqueueRequest
impl From<DeadLetterRecord> for EnqueueRequest
Source§fn from(r: DeadLetterRecord) -> Self
fn from(r: DeadLetterRecord) -> Self
Replays a dead-lettered job into its original queue, consuming the record.
Auto Trait Implementations§
impl Freeze for EnqueueRequest
impl RefUnwindSafe for EnqueueRequest
impl Send for EnqueueRequest
impl Sync for EnqueueRequest
impl Unpin for EnqueueRequest
impl UnsafeUnpin for EnqueueRequest
impl UnwindSafe for EnqueueRequest
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