#amqp #rabbitmq #futures #tokio #tls

lapin-futures-tls-api

Integration of tls-api with lapin-futures

22 releases (breaking)

✓ Uses Rust 2018 edition

0.19.1 Mar 11, 2020
0.19.0 May 27, 2019
0.18.0 Mar 3, 2019
0.14.1 Dec 5, 2018
0.3.0 Jul 13, 2017

#631 in Network programming

Download history 46/week @ 2019-11-29 392/week @ 2019-12-06 1/week @ 2019-12-13 1/week @ 2019-12-20 23/week @ 2019-12-27 1/week @ 2020-01-03 377/week @ 2020-01-10 162/week @ 2020-01-17 14/week @ 2020-01-24 8/week @ 2020-01-31 28/week @ 2020-02-07 4/week @ 2020-02-14 79/week @ 2020-02-21 33/week @ 2020-02-28 58/week @ 2020-03-06 31/week @ 2020-03-13

260 downloads per month
Used in batch

BSD-2-Clause

33KB
256 lines

DEPRECATED, use lapin directly instead


lib.rs:

lapin-futures-tls-api

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

Connecting and opening a channel

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

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

    tokio::run(
        "amqps://user:pass@host/vhost?heartbeat=10".connect_cancellable::<tls_api_stub::TlsConnector, _>(|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
~271K SLoC