24 releases (1 stable)

1.0.0 Dec 23, 2020
0.3.1 Nov 21, 2020
0.2.1 Oct 19, 2020
0.1.3 Jun 26, 2020
0.0.0 Apr 11, 2020

#139 in Database interfaces

Download history 842/week @ 2020-12-25 1690/week @ 2021-01-01 1964/week @ 2021-01-08 1776/week @ 2021-01-15 2037/week @ 2021-01-22 2412/week @ 2021-01-29 1986/week @ 2021-02-05 1910/week @ 2021-02-12 2227/week @ 2021-02-19 2370/week @ 2021-02-26 2061/week @ 2021-03-05 2239/week @ 2021-03-12 2186/week @ 2021-03-19 2062/week @ 2021-03-26 1616/week @ 2021-04-02 2270/week @ 2021-04-09

8,051 downloads per month
Used in less than 6 crates

MIT license

325KB
9K 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

~9MB
~185K SLoC