Expand description
Core abstractions for queuey.
This crate is transport-agnostic. It defines:
QueueSet: implemented (usually via#[derive(Queues)]) by an enum whose variants are the queues of an application.Job: implemented (usually via#[derive(Job)]) by a serializable payload type. A job statically knows which queue (variant) it belongs to.JobHandler: user code that processes one job type.Backend: a message transport (RabbitMQ, in-memory, …).Producer/Worker: the runtime that ties everything together.RetryPolicy/Backoff: optional (exponential) retry configuration.- Deferral: a handler returns
JobError::Deferred(or a producer callsProducer::defer) to park a job for an exact delay and have it come back ahead of the backlog, atQueueConfig::max_priority, without spending an attempt. The motivating case is an API answering429withRetry-After.
Module structure and public API below is the contract shared by the macro crate and the backend crates. Keep signatures stable; extend rather than change.
Re-exports§
pub use backend::Backend;pub use backend::Delivery;pub use backend::DeliveryStream;pub use envelope::Envelope;pub use error::Error;pub use error::JobError;pub use error::Result;pub use handler::FnHandler;pub use handler::JobContext;pub use handler::JobHandler;pub use job::Job;pub use memory::MemoryBackend;pub use producer::Producer;pub use queue::DEFAULT_MAX_PRIORITY;pub use queue::QueueConfig;pub use queue::QueueSet;pub use retry::Backoff;pub use retry::RetryDecision;pub use retry::RetryPolicy;pub use worker::Worker;pub use worker::WorkerBuilder;pub use worker::WorkerHandle;
Modules§
- backend
- Transport abstraction:
Backend,DeliveryandDeliveryStream. - envelope
- The
Envelope: the wire format every job travels in. - error
- Error types:
Errorfor infrastructure,JobErrorfor handlers. - handler
JobHandler, theJobContextit receives and theFnHandleradapter.- job
- The
Jobtrait: a serializable payload bound to one queue. - memory
- In-memory backend for tests and local development.
- producer
- The
Producer: type-safe publishing into a queue set. - queue
- Queue declarations:
QueueSetandQueueConfig. - retry
- Retry configuration:
RetryPolicy,Backoffand the backoff math. - worker
- Worker runtime.