Skip to main content

EnqueueRequest

Struct EnqueueRequest 

Source
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

Source

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.

Source

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).

Source

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.

Source

pub fn with_priority(self, priority: Priority) -> Self

Overrides the queue’s default Priority.

Source

pub fn with_max_attempts(self, attempts: u32) -> Self

Overrides the queue’s default maximum delivery attempts before the job is dead-lettered.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> EnqueueRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EnqueueRequest

Source§

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

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

impl From<&DeadLetterRecord> for EnqueueRequest

Source§

fn from(r: &DeadLetterRecord) -> Self

Replays a dead-lettered job into its original queue, leaving the record intact.

Source§

impl From<DeadLetterRecord> for EnqueueRequest

Source§

fn from(r: DeadLetterRecord) -> Self

Replays a dead-lettered job into its original queue, consuming the record.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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