#amqp #rabbitmq #futures #tokio #tls

lapin-futures-rustls

Integration of rustls with lapin-futures

24 releases (breaking)

✓ Uses Rust 2018 edition

0.21.1 Mar 11, 2020
0.21.0 Mar 3, 2019
0.20.0 Feb 15, 2019
0.17.1 Dec 5, 2018
0.7.0 Jul 13, 2017

#650 in Network programming

Download history 55/week @ 2019-12-02 558/week @ 2019-12-09 2/week @ 2019-12-16 26/week @ 2019-12-23 2/week @ 2019-12-30 1/week @ 2020-01-06 445/week @ 2020-01-13 153/week @ 2020-01-20 4/week @ 2020-01-27 7/week @ 2020-02-03 30/week @ 2020-02-10 27/week @ 2020-02-17 82/week @ 2020-02-24 68/week @ 2020-03-09 32/week @ 2020-03-16

279 downloads per month
Used in batch

BSD-2-Clause and MPL-2.0 licenses

34KB
261 lines

DEPRECATED, use lapin directly instead


lib.rs:

lapin-futures-rustls

This library offers a nice integration of rustls with the lapin-futures library. It uses amq-protocol URI parsing feature and adds the connect and connect_cancellable methods to AMQPUri which will provide you with a lapin_futures::client::Client and optionally a lapin_futures::client::HeartbeatHandle wrapped in a Future.

It autodetects whether you're using amqp or amqps and opens either a raw TcpStream or a TlsStream using rustls as the SSL engine.

Connecting and opening a channel

use env_logger;
use failure::Error;
use futures::future::Future;
use lapin_futures_rustls::{AMQPConnectionRustlsExt, lapin};
use lapin::channel::ConfirmSelectOptions;
use tokio;

fn main() {
    env_logger::init();

    tokio::run(
        "amqps://user:pass@host/vhost?heartbeat=10".connect_cancellable(|err| {
            eprintln!("heartbeat error: {:?}", err);
        }).map_err(Error::from).and_then(|(client, heartbeat_handle)| {
            println!("Connected!");
            client.create_confirm_channel(ConfirmSelectOptions::default()).map(|channel| (channel, heartbeat_handle)).and_then(|(channel, heartbeat_handle)| {
                println!("Stopping heartbeat.");
                heartbeat_handle.stop();
                println!("Closing channel.");
                channel.close(200, "Bye")
            }).map_err(Error::from)
        }).map_err(|err| {
            eprintln!("amqp error: {:?}", err);
        })
    );
}

Dependencies

~20MB
~478K SLoC