14 releases (3 stable)

1.2.0 Feb 17, 2021
1.1.0 Nov 21, 2020
1.0.0 Oct 31, 2020
0.4.1 Oct 16, 2020
0.1.4 Jul 23, 2020

#463 in Database interfaces

Download history 44/week @ 2020-12-24 143/week @ 2020-12-31 127/week @ 2021-01-07 168/week @ 2021-01-14 58/week @ 2021-01-21 63/week @ 2021-01-28 224/week @ 2021-02-04 157/week @ 2021-02-11 105/week @ 2021-02-18 74/week @ 2021-02-25 56/week @ 2021-03-04 77/week @ 2021-03-11 34/week @ 2021-03-18 104/week @ 2021-03-25 46/week @ 2021-04-01 285/week @ 2021-04-08

566 downloads per month
Used in 4 crates (3 directly)

MIT license

325KB
8K 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
~172K SLoC