Crate kanin

source · []
Expand description

kanin

A framework for AMQP built on top of lapin.

kanin makes it easy to create RPC microservices using protobuf in Rust with minimal boilerplate.

Example

// EchoRequest and EchoResponse are protobuf messages as generated by prost_build: https://docs.rs/prost-build/0.10.4/prost_build/index.html
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://localhost")
        .await
}

Re-exports

pub use lapin;
pub use app::App;
pub use error::Error;
pub use error::HandlerError;
pub use extract::Extract;
pub use handler::Handler;
pub use queue_config::QueueConfig;
pub use request::Request;
pub use response::Respond;

Modules

Module for the App struct and surrounding utilities.

Kanin-specific error types.

Interface for types that can extract themselves from requests.

Handlers are functions whose arguments can be constructed from the app or the incoming AMQP message.

Holds QueueConfig’s implementation.

AMQP requests.

AMQP responses.

Structs

A TCP connection to the AMQP server.

Type Definitions

Convenience type for a result with kanin’s error.

Derive Macros

Derives the kanin::error::FromError trait for a type. This only works under specific circumstances.