streamfly

Crates.iostreamfly
lib.rsstreamfly
version0.1.0
sourcesrc
created_at2023-09-16 07:30:50.53263
updated_at2023-09-16 07:30:50.53263
descriptionA stream-oriented Pub/Sub framework
homepage
repositoryhttps://github.com/netxp1318/streamfly
max_upload_size
id974207
size67,135
(netxp1318)

documentation

README

StreamFly

StreamFly aims to be a stream-oriented Pub/Sub framework.

Quickstart

  • create a streamfly client
let mut client = new_client(
    "127.0.0.1:1318".parse()?,
    "localhost",
    Path::new("./certs/cert.pem"),
)
.await?;
  • subscribe streams, and then receive data
let rx = client.subscribe(CHANNEL).await?;

loop {
    let (_, mut reader) = rx.recv().await?;

    tokio::spawn(async move { tokio::io::copy(&mut reader, &mut tokio::io::stdout()).await });
}
  • publish a stream, and then write data to the stream
let (stream_id, mut writer) = client.open_stream(CHANNEL).await?;

writer.write_all(b"Hello, Streamfly!").await?;

Build

  • build streamfly cli command
RUSTFLAGS="--cfg s2n_quic_unstable" cargo build
  • build examples
RUSTFLAGS="--cfg s2n_quic_unstable" cargo build --examples

Run the demo

  • start the streamfly server
RUST_LOG=debug ./target/debug/streamfly serve
  • start a receiver
RUST_LOG=debug ./target/debug/examples/sub
  • start a sender
RUST_LOG=debug ./target/debug/examples/pub
  • you can start another receiver
RUST_LOG=debug ./target/debug/examples/sub
Commit count: 28

cargo fmt