Skip to main content

Worker

Struct Worker 

Source
pub struct Worker { /* private fields */ }

Implementations§

Source§

impl Worker

Source

pub async fn connect(dsn: &str, queue: &str) -> Result<Self>

Connect with the nats://[user:password@]host[:port] DSN Broker\Nats takes (its query configures provisioning and is not read here) and join queue.

Source

pub async fn join(js: Context, queue: &str) -> Result<Self>

Join queue on an existing JetStream context.

Source

pub async fn receive( &self, max: usize, expires: Duration, ) -> Result<Vec<Delivery>>

Up to max messages, waiting at most expires for the first.

The rest are only what arrives within a short top-up, as in Broker\Nats::pull(): a batch the consumer’s maxAckPending will not let fill would otherwise hold the first messages, unextended, for all of expires.

A message no worker could read, or one on its spare delivery, is dead-lettered here and not returned, as Broker\Nats parks it.

Source

pub async fn commit(&self, delivery: Delivery) -> Result<()>

The message is done with.

Source

pub async fn reject(&self, delivery: Delivery, terminal: bool) -> Result<()>

The message failed. It comes back after the queue’s backoff or, on its last attempt or when terminal, goes to the dead stream, where PHP’s retry() can requeue it.

Source

pub async fn extend(&self, delivery: &Delivery) -> Result<()>

Keep a message that is still being worked on from coming back for another ack wait.

Source

pub async fn hold<F: Future>( &self, deliveries: &[&Delivery], work: F, ) -> F::Output

Run work while holding deliveries: each is extended every third of the ack wait (Broker\Nats::extendInterval()), so none is redelivered to another worker while this one is still on it.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Worker

§

impl !UnwindSafe for Worker

§

impl Forget for Worker

§

impl Freeze for Worker

§

impl Move for Worker

§

impl Send for Worker

§

impl Sync for Worker

§

impl Unpin for Worker

§

impl UnsafeUnpin for Worker

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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