ztx 1.0.0

ZTX is a simple & fast RoQ (RPC over QUIC) framework built using TQUIC
Documentation
  • Coverage
  • 0%
    0 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 67.46 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.82 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 16s Average build duration of successful builds.
  • all releases: 2m 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Akzestia/ZTX
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Akzestia

ZTX

ZTX - a simple, fast RoQ (RPC over QUIC) framework, built using TQUIC.

Performance

ZTX can be as fast as 4x the speed of gRPC, but you should note that ZTX contains a wide range of specific optimizations, so creating a fair benchmark is a bit complicated

Usage

Setting up server

fn main() -> Result<()> {
    register_rpc(&RPC_ECHO);
    register_rpc(&RPC_HELLO);

    let settings = ServerSettings::builder()
        .workers(num_cpus::get())
        .listen("0.0.0.0:4433".parse().unwrap())
        .cert_file("cert.crt")
        .key_file("cert.key")
        .build();

    run_server(settings)
}

Register RPC (Server side)

// Define echo RPC
#[rpc("echo")]
pub async fn echo(_ctx: RpcContext, input: Vec<u8>) -> RpcResult<Vec<u8>> {
    Ok(input)
}

// Register RPC
fn main() -> Result<()> {
    // You must register ALL of your defined RPCs before run_server()
    register_rpc(&RPC_ECHO);

    // Server setup
    // ...
    run_server(settings)
}

Setting up client

#[tokio::main]
async fn main() -> Result<()> {
    let server: SocketAddr = "127.0.0.1:4433".parse().unwrap();
    // Optional: log connection
    info!("connecting to {}", server);

    let mut client = QuicRpcClient::builder(server).idle_timeout(5_000).build()?;
}

Calling RPC (Client side)

// RPC with payload
let resp = client.call_with("echo", b"hello world")?;
println!("echo => {}", String::from_utf8_lossy(&resp));
// RPC without payload
let _ = client.call("ping")?;

Docs

More info available in docs folder

License MIT