spectacles-brokers 1.3.0

Message brokers which allow for powerful communication between Spectacles services.
Documentation

Crates.io Crates.io Crates.io

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 std::net::SocketAddr;
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();
        broker.publish(
            "HELLO", 
            json.to_vec(), 
            AmqpProperties::default().with_content_type("application/json".to_string()
        )
    });
    let success = result.map(|_| {
        println!("Message publish succeeded, check the other window!");
    }).map_err(|err| {
        eprintln!("An error was encountered during publish: {}", err);
    });

    tokio::run(success);
}

More examples can be found in the [examples] directory.