-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide a rich readme for fluvio crate (#3303)
- Includes a small walkthrough on Fluvio - Reuses crate README for docs - Provides links of interest
- Loading branch information
1 parent
e093e09
commit 59fe3b4
Showing
3 changed files
with
140 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,138 @@ | ||
# Fluvio | ||
<div align="center"> | ||
<h1>Fluvio</h1> | ||
<a href="https://fluvio.io" target="_blank"> | ||
<strong>The programmable data streaming platform</strong> | ||
</a> | ||
</div> | ||
|
||
The official Fluvio Rust client. | ||
<div align="center"> | ||
|
||
<a href="https://github.com/infinyon/fluvio"> | ||
<img src="https://github.com/infinyon/fluvio/workflows/CI/badge.svg?branch=master" alt="Fluvio CI on Github" /> | ||
</a> | ||
[![CI Status](https://github.com/infinyon/fluvio/workflows/CI/badge.svg)](https://github.com/infinyon/fluvio/actions/workflows/ci.yml) | ||
[![CD Status](https://github.com/infinyon/fluvio/workflows/CD_Dev/badge.svg)](https://github.com/infinyon/fluvio/actions/workflows/cd_dev.yaml) | ||
[![fluvio Crates.io version](https://img.shields.io/crates/v/fluvio?style=flat)](https://crates.io/crates/fluvio) | ||
[![Fluvio Rust documentation](https://docs.rs/fluvio/badge.svg)](https://docs.rs/fluvio) | ||
[![Fluvio dependency status](https://deps.rs/repo/github/infinyon/fluvio/status.svg)](https://deps.rs/repo/github/infinyon/fluvio) | ||
[![Fluvio Discord](https://img.shields.io/discord/695712741381636168.svg?logo=discord&style=flat)](https://discordapp.com/invite/bBG2dTz) | ||
|
||
<a href="https://crates.io/crates/fluvio"> | ||
<img src="https://img.shields.io/crates/v/fluvio" alt="Fluvio on Crates.io" /> | ||
</a> | ||
</div> | ||
|
||
<a href="https://docs.rs/fluvio"> | ||
<img src="https://docs.rs/fluvio/badge.svg" alt="Fluvio documentation" /> | ||
</a> | ||
## What's Fluvio? | ||
|
||
<a href="https://discordapp.com/invite/bBG2dTz"> | ||
<img src="https://img.shields.io/discord/695712741381636168.svg?logo=discord&style=flat" alt="Discord chat" /> | ||
</a> | ||
Fluvio is a programmable data streaming platform written in Rust. With Fluvio | ||
you can create performant real time applications that scale. | ||
|
||
[Fluvio] is a distributed streaming platform for building real-time applications, | ||
written from the ground up in Rust. | ||
Read more about Fluvio in the [official website][Fluvio.io]. | ||
|
||
[Fluvio]: https://www.fluvio.io/ | ||
## Getting Started | ||
|
||
## License | ||
Let's write a very simple solution with Fluvio, in the following demostration | ||
we will create a topic using the Fluvio CLI and then we wisll produce some | ||
records on this topic. Finally these records will be consumed from the topic | ||
and printed to the stdout. | ||
|
||
This project is licensed under the [Apache license](LICENSE-APACHE). | ||
1. Install [Fluvio CLI][Install Fluvio CLI] if you havent already | ||
|
||
### Contribution | ||
2. Create a new topic using the CLI | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted | ||
for inclusion in Fluvio by you, shall be licensed as Apache, without any additional | ||
terms or conditions. | ||
```bash | ||
fluvio topic create "echo-test" | ||
``` | ||
|
||
3. Create a new cargo project and install `fluvio`, `futures` and `async-std` | ||
|
||
```bash | ||
cargo add fluvio | ||
cargo add futures | ||
cargo add async-std --features attributes | ||
``` | ||
|
||
4. Copy and paste the following snippet into your `src/main.rs` | ||
|
||
```ignore | ||
use std::time::Duration; | ||
use fluvio::{Offset, RecordKey}; | ||
use futures::StreamExt; | ||
const TOPIC: &str = "echo-test"; | ||
const MAX_RECORDS: u8 = 10; | ||
#[async_std::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let producer = fluvio::producer(TOPIC).await?; | ||
let consumer = fluvio::consumer(TOPIC, 0).await?; | ||
let mut consumed_records: u8 = 0; | ||
for i in 0..10 { | ||
producer.send(RecordKey::NULL, format!("Hello from Fluvio {}!", i)).await?; | ||
println!("[PRODUCER] sent record {}", i); | ||
async_std::task::sleep(Duration::from_secs(1)).await; | ||
} | ||
// Fluvio batches records by default, call flush() when done producing | ||
// to ensure all records are sent | ||
producer.flush().await?; | ||
let mut stream = consumer.stream(Offset::beginning()).await?; | ||
while let Some(Ok(record)) = stream.next().await { | ||
let value_str = record.get_value().as_utf8_lossy_string(); | ||
println!("[CONSUMER] Got record: {}", value_str); | ||
consumed_records += 1; | ||
if consumed_records >= MAX_RECORDS { | ||
break; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
``` | ||
|
||
5. Run `cargo run` and expect the following output | ||
|
||
```txt | ||
[PRODUCER] sent record 0 | ||
[PRODUCER] sent record 1 | ||
[PRODUCER] sent record 2 | ||
[PRODUCER] sent record 3 | ||
[PRODUCER] sent record 4 | ||
[PRODUCER] sent record 5 | ||
[PRODUCER] sent record 6 | ||
[PRODUCER] sent record 7 | ||
[PRODUCER] sent record 8 | ||
[PRODUCER] sent record 9 | ||
[CONSUMER] Got record: Hello, Fluvio 0! | ||
[CONSUMER] Got record: Hello, Fluvio 1! | ||
[CONSUMER] Got record: Hello, Fluvio 2! | ||
[CONSUMER] Got record: Hello, Fluvio 3! | ||
[CONSUMER] Got record: Hello, Fluvio 4! | ||
[CONSUMER] Got record: Hello, Fluvio 5! | ||
[CONSUMER] Got record: Hello, Fluvio 6! | ||
[CONSUMER] Got record: Hello, Fluvio 7! | ||
[CONSUMER] Got record: Hello, Fluvio 8! | ||
[CONSUMER] Got record: Hello, Fluvio 9! | ||
``` | ||
|
||
6. Clean Up | ||
|
||
```bash | ||
fluvio topic delete echo-test | ||
topic "echo-test" deleted | ||
``` | ||
|
||
## Learn More | ||
|
||
- [Read on tutorials][Tutorials] to get the most from Fluvio and InfinyOn Cloud | ||
to scale your streaming solution. | ||
|
||
- You can use Fluvio to send or receive records from different sources using [Connectors][Connectors]. | ||
|
||
- If you want to filter or transform records on the fly read more about [SmartModules][SmartModules]. | ||
|
||
[Fluvio.io]: https://www.fluvio.io | ||
[Install Fluvio CLI]: https://www.fluvio.io/cli/ | ||
[Connectors]: https://www.fluvio.io/connectors/ | ||
[SmartModules]: https://www.fluvio.io/smartmodules/ | ||
[Tutorials]: https://www.fluvio.io/docs/tutorials/cloud-setup/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters