tokio-amqp

Crates.iotokio-amqp
lib.rstokio-amqp
version2.0.0
sourcesrc
created_at2020-04-11 14:30:03.456909
updated_at2022-02-02 20:01:48.874642
descriptionlapin integration with tokio
homepage
repositoryhttps://github.com/amqp-rs/lapin
max_upload_size
id228672
size41,098
Marc-Antoine Perennou (Keruspe)

documentation

https://docs.rs/tokio-amqp

README

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() -> 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()).await?; // Note the `with_tokio()` here
    let channel = conn.create_channel().await?;

    // Rest of your program
}

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

cargo fmt