#discord #spec #broker #spectacles #communication #service #amqp

spectacles-brokers

Message brokers which allow for powerful communication between Spectacles services

13 stable releases

1.4.0 Apr 13, 2019
1.3.1 Mar 19, 2019

#86 in #amqp


Used in spectacles

MIT license

14KB
206 lines

crates-io-badge Downloads docs-badge

Spectacles Brokers

Message brokers which allow for simple communication between Spectacles services.

Available Brokers

  • AMQP - An interface to connect to an AMQP-compliant server.

Example: AMQP Publisher

use std::env::var;
use futures::future::Future;
use spectacles_brokers::amqp::*;

fn main() {
    let addr = var("AMQP_ADDR").expect("No AMQP server address found.");
    let connect = AmqpBroker::new(addr, "test".to_string(), None);
    let result = connect.and_then(|broker| {
        let json = r#"{"message": "Example Publish."}"#.as_bytes();
        let props = AmqpProperties::default().with_content_type("application/json".to_string();
        broker.publish("HELLO", json.to_vec(), props).map_err(|err| {
            eprintln!("An error was encountered during publish: {}", err);
        })
    }).map(|_| {
        println!("Message publish succeeded, check the other window!");
    })

    tokio::run(result);
}

More examples can be found in the examples directory.

Dependencies

~18–31MB
~485K SLoC