13 releases (2 stable)

new 1.1.0 Nov 21, 2020
1.0.0 Oct 31, 2020
0.4.1 Oct 16, 2020
0.4.0 Sep 7, 2020
0.1.4 Jul 23, 2020

#598 in Database interfaces

Download history 7/week @ 2020-08-02 34/week @ 2020-08-09 19/week @ 2020-08-16 36/week @ 2020-08-23 23/week @ 2020-08-30 69/week @ 2020-09-06 19/week @ 2020-09-13 42/week @ 2020-09-20 91/week @ 2020-09-27 49/week @ 2020-10-04 51/week @ 2020-10-11 36/week @ 2020-10-18 77/week @ 2020-10-25 180/week @ 2020-11-01 37/week @ 2020-11-08 24/week @ 2020-11-15

247 downloads per month
Used in 3 crates

MIT license

335KB
9K SLoC

Lapin integration with async-io

This crate integrates lapin with async-io by using async-io's reactor inside of lapin.

use async_lapin::*;
use lapin::{executor::Executor, Connection, ConnectionProperties, Result};
use std::{future::Future, pin::Pin};

#[derive(Debug)]
struct SmolExecutor;

impl Executor for SmolExecutor {
    fn spawn(&self, f: Pin<Box<dyn Future<Output = ()> + Send>>) -> Result<()> {
        smol::spawn(f).detach();
        Ok(())
    }
}

fn main() -> Result<()> {
    smol::block_on(async {
        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_async_io(SmolExecutor)
        )
        .await?; // Note the `with_async_io()` here
        let channel = conn.create_channel().await?;

        // Rest of your program
    })
}

Dependencies

~7.5MB
~167K SLoC