Crate omniqueue

source ·
Expand description

§Omniqueue

Omniqueue provides a high-level interface for sending and receiving the following over a range of queue backends:

§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

§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§

Modules§

Structs§

Enums§

Traits§

Type Aliases§

  • Type alias for std’s Result with the error type defaulting to omniqueue’s QueueError.