Crates.io | kanin |
lib.rs | kanin |
version | 0.32.1 |
source | src |
created_at | 2022-06-15 13:44:26.116241 |
updated_at | 2024-04-24 08:02:53.271395 |
description | An RPC microservice framework for AMQP, protobuf and Rust built on lapin (https://github.com/amqp-rs/lapin). |
homepage | |
repository | https://github.com/issuu/kanin |
max_upload_size | |
id | 606508 |
size | 83,178 |
A framework for AMQP built on top of lapin that makes it easy to create RPC microservices in Rust 🦀, using Protobuf.
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.
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.