#server #data-streaming #rpc #async #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

#577 in Asynchronous

47 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–11MB
~116K SLoC