#amqp #rabbitmq #futures #tokio #tls

lapin-futures-native-tls

Integration of native-tls with lapin-futures

15 releases (9 breaking)

✓ Uses Rust 2018 edition

0.10.1 Mar 11, 2020
0.10.0 Mar 3, 2019
0.9.0 Feb 15, 2019
0.6.1 Dec 5, 2018
0.4.0 Jul 9, 2018

#617 in Network programming

Download history 34/week @ 2019-12-01 291/week @ 2019-12-08 177/week @ 2019-12-15 29/week @ 2019-12-22 36/week @ 2020-01-05 251/week @ 2020-01-12 98/week @ 2020-01-19 54/week @ 2020-01-26 148/week @ 2020-02-02 144/week @ 2020-02-09 20/week @ 2020-02-16 46/week @ 2020-02-23 10/week @ 2020-03-01 59/week @ 2020-03-08 49/week @ 2020-03-15

360 downloads per month
Used in 2 crates (via spectacles-brokers)

BSD-2-Clause

34KB
256 lines

DEPRECATED, use lapin directly instead


lib.rs:

lapin-futures-native-tls

This library offers a nice integration of native-tls 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 native-tls as the SSL engine.

Connecting and opening a channel

use env_logger;
use failure::Error;
use futures::future::Future;
use lapin_futures_native_tls::{AMQPConnectionNativeTlsExt, 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

~13MB
~277K SLoC