#handler #state

kanin

An RPC microservice framework for AMQP, protobuf and Rust built on lapin (https://github.com/amqp-rs/lapin)

19 releases (12 breaking)

0.25.0 Sep 7, 2023
0.23.1 Aug 21, 2023
0.22.2 Apr 18, 2023
0.22.1 Mar 22, 2023
0.17.0 Jul 25, 2022

#259 in Concurrency

Download history 127/week @ 2023-06-03 250/week @ 2023-06-10 121/week @ 2023-06-17 159/week @ 2023-06-24 191/week @ 2023-07-01 103/week @ 2023-07-08 62/week @ 2023-07-15 65/week @ 2023-07-22 208/week @ 2023-07-29 201/week @ 2023-08-05 54/week @ 2023-08-12 160/week @ 2023-08-19 188/week @ 2023-08-26 150/week @ 2023-09-02 233/week @ 2023-09-09 147/week @ 2023-09-16

744 downloads per month

MIT/Apache

68KB
1K SLoC

🐰 kanin

Crates.io version Documentation status

A framework for AMQP built on top of lapin that makes it easy to create RPC microservices in Rust 🦀, using Protobuf.

Usage

Run cargo add kanin to add kanin to your Cargo.toml.

mod protobuf;

use kanin::{extract::Msg, App};
use protobuf::echo::{EchoRequest, EchoResponse};

async fn echo(Msg(request): Msg<EchoRequest>) -> EchoResponse {
    EchoResponse::success(request.value)
}

#[tokio::main]
async fn main() -> kanin::Result<()> {
    App::new()
        .handler("my_routing_key", echo)
        .run("amqp_addr")
        .await
}

See the documentation for examples and more specific usage, or see the /minimal_example folder in this repo.

Testing

To run tests, install just and Docker (you need docker-compose).

Then, simply run just test, which will launch a RabbitMQ instance in a container that the tests will connect to.

Dependencies

~13–27MB
~394K SLoC