Expand description
§Omniqueue
Omniqueue provides a high-level interface for sending and receiving the following over a range of queue backends:
- Raw byte arrays in the way most compatible with the queue backend
- JSON encoded byte arrays for types that implement
serde::Deserializeandserde::Serialize
§Cargo Features
Each backend is enabled with its associated cargo feature. All backends are enabled by default. As of present it supports:
- In-memory queue
- Google Cloud Pub/Sub
- RabbitMQ
- Redis
- Amazon SQS
- Azure Queue Storage
§How to Use Omniqueue
Each queue backend has a unique configuration type. One of these
configurations is taken when constructing the QueueBuilder.
To create a simple producer and/or consumer:
use omniqueue::backends::{SqsConfig, SqsBackend};
let cfg = SqsConfig {
queue_dsn: "http://localhost:9234/queue/queue_name".to_owned(),
override_endpoint: true,
};
// Either both producer and consumer
let (p, mut c) = SqsBackend::builder(cfg.clone()).build_pair().await?;
// Or one half
let p = SqsBackend::builder(cfg.clone()).build_producer().await?;
let mut c = SqsBackend::builder(cfg).build_consumer().await?;Sending and receiving information from this queue is simple:
p.send_serde_json(&ExampleType::default()).await?;
let delivery = c.receive().await?;
let payload = delivery.payload_serde_json::<ExampleType>()?;
delivery.ack().await.map_err(|(e, _)| e)?;§DynProducers and DynConsumers
Dynamic-dispatch can be used easily for when you’re not sure which backend to use at compile-time.
Making a DynProducer or DynConsumer is as simple as adding one line to
the builder:
use omniqueue::backends::RabbitMqBackend;
let (p, mut c) = RabbitMqBackend::builder(cfg)
.make_dynamic()
.build_pair()
.await?;Re-exports§
pub use self::builder::QueueBuilder;
Modules§
Structs§
- Delivery
- The output of queue backends
- DynConsumer
- DynProducer
- DynScheduled
Producer
Enums§
Traits§
- Queue
Backend Deprecated - A marker trait with utility functions meant for the creation of new producers and/or consumers.
- Queue
Consumer - Queue
Payload - Queue
Producer - Scheduled
Queue Producer
Type Aliases§
- Result
- Type alias for std’s
Resultwith the error type defaulting to omniqueue’sQueueError.