7 unstable releases

0.5.2 Nov 30, 2024
0.5.1 Sep 2, 2024
0.5.0 Apr 24, 2024
0.3.0 Jul 11, 2023
0.1.0 Mar 2, 2023

#429 in Concurrency

Download history 573/week @ 2024-08-22 606/week @ 2024-08-29 513/week @ 2024-09-05 515/week @ 2024-09-12 533/week @ 2024-09-19 553/week @ 2024-09-26 763/week @ 2024-10-03 468/week @ 2024-10-10 468/week @ 2024-10-17 473/week @ 2024-10-24 580/week @ 2024-10-31 583/week @ 2024-11-07 582/week @ 2024-11-14 710/week @ 2024-11-21 800/week @ 2024-11-28 495/week @ 2024-12-05

2,710 downloads per month
Used in 8 crates (2 directly)

MIT/Apache

230KB
5K SLoC

sea-streamer-socket: Backend-agnostic Socket API

Akin to how SeaORM allows you to build applications for different databases, SeaStreamer allows you to build stream processors for different streaming servers.

While the sea-streamer-types crate provides a nice trait-based abstraction, this crates provides a concrete-type API, so that your program can stream from/to any SeaStreamer backend selected by the user on runtime.

This allows you to do neat things, like generating data locally and then stream them to Redis / Kafka. Or in the other way, sink data from server to work on them locally. All without recompiling the stream processor.

If you only ever work with one backend, feel free to depend on sea-streamer-redis / sea-streamer-kafka directly.

A small number of cli programs are provided for demonstration. Let's set them up first:

# The `clock` program generate messages in the form of `{ "tick": N }`
alias clock='cargo run --package sea-streamer-stdio  --features=executables --bin clock'
# The `relay` program redirect messages from `input` to `output`
alias relay='cargo run --package sea-streamer-socket --features=executables,backend-kafka,backend-redis --bin relay'

Here is how to stream from Stdio ➡️ Redis / Kafka. We generate messages using clock and then pipe it to relay, which then streams to Redis / Kafka:

# Stdio -> Redis
clock -- --stream clock --interval 1s | \
relay -- --input stdio:///clock --output redis://localhost:6379/clock
# Stdio -> Kafka
clock -- --stream clock --interval 1s | \
relay -- --input stdio:///clock --output kafka://localhost:9092/clock

Here is how to stream between Redis ↔️ Kafka:

# Redis -> Kafka
relay -- --input redis://localhost:6379/clock --output kafka://localhost:9092/clock
# Kafka -> Redis
relay -- --input kafka://localhost:9092/clock --output redis://localhost:6379/clock

Here is how to replay the stream from Kafka / Redis:

relay -- --input redis://localhost:6379/clock --output stdio:///clock --offset start
relay -- --input kafka://localhost:9092/clock --output stdio:///clock --offset start

Dependencies

~3–18MB
~248K SLoC