#server #data-streaming #async #rpc #full-duplex

kumoko

A simple asynchronous server/client crate built on tokio for easy two-way streaming

13 releases

0.6.0 Jun 28, 2023
0.5.6 Dec 7, 2022
0.5.5 Oct 27, 2022
0.5.3 Aug 15, 2022
0.3.4 Jul 26, 2022

#432 in Asynchronous

Download history 13/week @ 2024-02-22 11/week @ 2024-02-29 5/week @ 2024-03-07 3/week @ 2024-03-14 66/week @ 2024-03-28 35/week @ 2024-04-04

101 downloads per month

MIT/Apache

30KB
560 lines

Kumoko

A simple asynchronous server/client crate built on tokio for easy two-way streaming.

crates-badge docs.rs license

Website | API Docs

Unstable Warning!

  • Early in development
  • The documentation is lacking
  • Limited tests

Motivation

Enable asynchronous full duplex streaming of semi-complex data-structures between a rust server and clients. gRPC implementations are suboptimal for this:

  • Unnecessary complexity
  • Annoying Protocol buffers
  • Restricted Data e.g. no enums

Features

  • Many Clients can communicate with the Server asynchronously
  • Every Client has a full duplex connection
  • Any data structure that implements Message can be transmitted:
trait Message: Send + Encode + Decode + 'static

Examples

In your Cargo.toml:

[dependencies]
kumoko = "0.5"
tokio = { version = "1.20", features = ["macros", "rt-multi-thread"] }

Minimal Client:

use kumoko::client::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Client::connect("[::1]:50052").await?;

    client.emit_request("Ferris".to_string()).await;
    let msg: String = client.get_response().await.unwrap();
    println!("{}", msg);

    Ok(())
}

Minimal Server:

use kumoko::server::Server;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut server = Server::<String, String>::bind("[::1]:50052").await?;
    
    loop{
        let (req, origin) = server.get_request().await;

        let msg = format!("Hello {}! Happy to see you here!", req);
        server.emit_response(msg, origin.into()).await;
    }
}

Dependencies

~3–14MB
~135K SLoC