sea_streamer_socket/lib.rs
1//! ### `sea-streamer-socket`: Backend-agnostic Socket API
2//!
3//! Akin to how SeaORM allows you to build applications for different databases, SeaStreamer allows you to build
4//! stream processors for different streaming servers.
5//!
6//! While the `sea-streamer-types` crate provides a nice trait-based abstraction, this crates provides a concrete-type API,
7//! so that your program can stream from/to any SeaStreamer backend selected by the user *on runtime*.
8//!
9//! This allows you to do neat things, like generating data locally and then stream them to Redis / Kafka. Or in the other
10//! way, sink data from server to work on them locally. All _without recompiling_ the stream processor.
11//!
12//! If you only ever work with one backend, feel free to depend on `sea-streamer-redis` / `sea-streamer-kafka` directly.
13//!
14//! A small number of cli programs are provided for demonstration. Let's set them up first:
15//!
16//! ```shell
17//! # The `clock` program generate messages in the form of `{ "tick": N }`
18//! alias clock='cargo run --package sea-streamer-stdio --features=executables --bin clock'
19//! # The `relay` program redirect messages from `input` to `output`
20//! alias relay='cargo run --package sea-streamer-socket --features=executables,backend-kafka,backend-redis --bin relay'
21//! ```
22//!
23//! Here is how to stream from Stdio ➡️ Redis / Kafka. We generate messages using `clock` and then pipe it to `relay`,
24//! which then streams to Redis / Kafka:
25//!
26//! ```shell
27//! # Stdio -> Redis
28//! clock -- --stream clock --interval 1s | \
29//! relay -- --input stdio:///clock --output redis://localhost:6379/clock
30//! # Stdio -> Kafka
31//! clock -- --stream clock --interval 1s | \
32//! relay -- --input stdio:///clock --output kafka://localhost:9092/clock
33//! ```
34//!
35//! Here is how to stream between Redis ↔️ Kafka:
36//!
37//! ```shell
38//! # Redis -> Kafka
39//! relay -- --input redis://localhost:6379/clock --output kafka://localhost:9092/clock
40//! # Kafka -> Redis
41//! relay -- --input kafka://localhost:9092/clock --output redis://localhost:6379/clock
42//! ```
43//!
44//! Here is how to *replay* the stream from Kafka / Redis:
45//!
46//! ```shell
47//! relay -- --input redis://localhost:6379/clock --output stdio:///clock --offset start
48//! relay -- --input kafka://localhost:9092/clock --output stdio:///clock --offset start
49//! ```
50
51#![cfg_attr(docsrs, feature(doc_cfg))]
52#![deny(missing_debug_implementations)]
53#![doc(
54 html_logo_url = "https://raw.githubusercontent.com/SeaQL/sea-streamer/main/docs/SeaQL icon.png"
55)]
56
57mod backend;
58mod connect_options;
59mod consumer;
60mod consumer_options;
61mod error;
62mod message;
63mod producer;
64mod producer_options;
65mod streamer;
66
67pub use backend::*;
68pub use connect_options::*;
69pub use consumer::*;
70pub use consumer_options::*;
71pub use error::*;
72pub use message::*;
73pub use producer::*;
74pub use producer_options::*;
75pub use streamer::*;