Skip to main content

Crate utopia_queue

Crate utopia_queue 

Source
Expand description

Queue workers that share their queues with utopia-php/queue.

Worker consumes a queue on NATS JetStream the way Utopia\Queue\Broker\Nats does, so a Rust worker and PHP workers can take messages from the same queue at the same time:

  • It joins the worker durable consumer on the Q_<NAME> stream that Broker\Nats provisions. It provisions nothing itself: publishers create the stream on their first publish, and a worker started before that waits for it.
  • Messages are the JSON envelope Broker\Nats writes: pid, queue, timestamp and payload.
  • The redelivery budget and the backoff are read from the consumer, which carries the values the queue’s DSN gave it, so this worker retries exactly as the PHP ones do.
  • What Broker\Nats dead-letters, this dead-letters to the same subjects with the same headers, so retry() in PHP requeues it.

What stays with the PHP workers sharing the queue: provisioning, the max-deliveries advisory and reap(). Both of the last two only matter for a message whose every delivery died unacknowledged, which Worker::receive dead-letters itself on its spare delivery.

Structs§

Delivery
A message taken from the queue, held until it is committed or rejected.
Envelope
A message as Broker\Nats enqueues it.
Worker

Enums§

Error

Type Aliases§

Result