pub struct Producer { /* private fields */ }Expand description
Producer for enqueueing messages to a queue.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn new(
store: AnyStore,
queue_info: QueueRecord,
worker_record: WorkerRecord,
validation_config: ValidationConfig,
) -> Self
pub fn new( store: AnyStore, queue_info: QueueRecord, worker_record: WorkerRecord, validation_config: ValidationConfig, ) -> Self
Create a producer bound to a queue and worker record.
Sourcepub fn with_time(self, time: DateTime<Utc>) -> Self
pub fn with_time(self, time: DateTime<Utc>) -> Self
Set the current time used for enqueue timestamps.
Sourcepub fn current_time(&self) -> DateTime<Utc>
pub fn current_time(&self) -> DateTime<Utc>
Return the current time used for enqueue timestamps.
Sourcepub fn worker_record(&self) -> &WorkerRecord
pub fn worker_record(&self) -> &WorkerRecord
Return the worker record for this producer.
Sourcepub async fn status(&self) -> Result<WorkerStatus>
pub async fn status(&self) -> Result<WorkerStatus>
Fetch the current worker status.
Sourcepub async fn is_healthy(&self, max_age: Duration) -> Result<bool>
pub async fn is_healthy(&self, max_age: Duration) -> Result<bool>
Check if the worker heartbeat is within the given age.
Sourcepub async fn get_message_by_id(&self, msg_id: i64) -> Result<QueueMessage>
pub async fn get_message_by_id(&self, msg_id: i64) -> Result<QueueMessage>
Fetch a message by id.
Sourcepub async fn enqueue(&self, payload: &Value) -> Result<QueueMessage>
pub async fn enqueue(&self, payload: &Value) -> Result<QueueMessage>
Enqueue a message immediately.
Sourcepub async fn enqueue_delayed(
&self,
payload: &Value,
delay_seconds: u32,
) -> Result<QueueMessage>
pub async fn enqueue_delayed( &self, payload: &Value, delay_seconds: u32, ) -> Result<QueueMessage>
Enqueue a message with a delay in seconds.
Sourcepub async fn batch_enqueue(
&self,
payloads: &[Value],
) -> Result<Vec<QueueMessage>>
pub async fn batch_enqueue( &self, payloads: &[Value], ) -> Result<Vec<QueueMessage>>
Enqueue multiple messages immediately.
Sourcepub async fn batch_enqueue_delayed(
&self,
payloads: &[Value],
delay_seconds: u32,
) -> Result<Vec<QueueMessage>>
pub async fn batch_enqueue_delayed( &self, payloads: &[Value], delay_seconds: u32, ) -> Result<Vec<QueueMessage>>
Enqueue multiple messages with a delay in seconds.
Sourcepub async fn enqueue_at(
&self,
payload: &Value,
now: DateTime<Utc>,
delay_seconds: u32,
) -> Result<QueueMessage>
pub async fn enqueue_at( &self, payload: &Value, now: DateTime<Utc>, delay_seconds: u32, ) -> Result<QueueMessage>
Enqueue a message using an explicit time reference.
Sourcepub async fn batch_enqueue_at(
&self,
payloads: &[Value],
now: DateTime<Utc>,
delay_seconds: u32,
) -> Result<Vec<QueueMessage>>
pub async fn batch_enqueue_at( &self, payloads: &[Value], now: DateTime<Utc>, delay_seconds: u32, ) -> Result<Vec<QueueMessage>>
Enqueue multiple messages using an explicit time reference.
Sourcepub async fn replay_dlq(
&self,
archived_msg_id: i64,
) -> Result<Option<QueueMessage>>
pub async fn replay_dlq( &self, archived_msg_id: i64, ) -> Result<Option<QueueMessage>>
Replay an archived DLQ message back into the queue.
Sourcepub fn validation_config(&self) -> &ValidationConfig
pub fn validation_config(&self) -> &ValidationConfig
Return the validation config for this producer.
Sourcepub fn rate_limit_status(&self) -> Option<RateLimitStatus>
pub fn rate_limit_status(&self) -> Option<RateLimitStatus>
Return the current rate limit status, if enabled.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Producer
impl !RefUnwindSafe for Producer
impl Send for Producer
impl Sync for Producer
impl Unpin for Producer
impl UnsafeUnpin for Producer
impl !UnwindSafe for Producer
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> 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 more