1 unstable release
0.1.0 | Sep 16, 2023 |
---|
#30 in #subscribe
21KB
505 lines
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
Dependencies
~16–25MB
~369K SLoC