21 releases

0.2.1 Oct 19, 2020
0.2.0 Oct 16, 2020
0.1.3 Jun 26, 2020
0.1.0 May 27, 2020
0.0.0 Apr 11, 2020

#118 in Database interfaces

Download history 1662/week @ 2020-07-07 1522/week @ 2020-07-14 1310/week @ 2020-07-21 1778/week @ 2020-07-28 1484/week @ 2020-08-04 1649/week @ 2020-08-11 1761/week @ 2020-08-18 1541/week @ 2020-08-25 1887/week @ 2020-09-01 2123/week @ 2020-09-08 1744/week @ 2020-09-15 2529/week @ 2020-09-22 2674/week @ 2020-09-29 2348/week @ 2020-10-06 1873/week @ 2020-10-13 2064/week @ 2020-10-20

8,070 downloads per month
Used in 4 crates

MIT license

295KB
7.5K SLoC

Lapin integration with tokio

This crate integrates lapin with tokio by using tokio's executor inside of lapin for its internal operations and for consumer delegates.

use tokio_amqp::*;
use lapin::{Connection, ConnectionProperties, Result};
use std::sync::Arc;
use tokio::runtime::Runtime;

async fn tokio_main(rt: Arc<Runtime>) -> Result<()> {
    let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://127.0.0.1:5672/%2f".into());
    let conn = Connection::connect(&addr, ConnectionProperties::default().with_tokio(rt)).await?; // Note the `with_tokio()` here
    let channel = conn.create_channel().await?;

    // Rest of your program
}

fn main() {
    let rt = Arc::new(Runtime::new().expect("failed to create runtime"));
    rt.block_on(tokio_main(rt.clone())).expect("error");
}

Dependencies

~7.5MB
~164K SLoC