From 7826c77e4bbf475650a9fb52ccf4f44b3af73fa1 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 14:48:02 -0400 Subject: [PATCH 1/8] feat: update example --- crates/fluvio/README.md | 107 +++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/crates/fluvio/README.md b/crates/fluvio/README.md index 10c1f57f5e..30e7e8aa8c 100644 --- a/crates/fluvio/README.md +++ b/crates/fluvio/README.md @@ -1,34 +1,97 @@ # Fluvio -The official Fluvio Rust client. +# Getting Started - -Fluvio CI on Github - +1. Install [Fluvio CLI][Install Fluvio CLI] if you havent already - -Fluvio on Crates.io - +2. Create a new topic using the CLI - -Fluvio documentation - +```bash +fluvio topic create "echo-test" +``` - -Discord chat - +3. Create a new cargo project and install `fluvio`, `futures` and `async-std` -[Fluvio] is a distributed streaming platform for building real-time applications, -written from the ground up in Rust. +```bash +cargo add fluvio +cargo add futures +cargo add async-std --features attributes +``` -[Fluvio]: https://www.fluvio.io/ +4. Copy and paste the following snippet into your `src/main.rs` -## License +```rust +use std::time::Duration; -This project is licensed under the [Apache license](LICENSE-APACHE). +use fluvio::{Offset, RecordKey}; +use futures::StreamExt; -### Contribution +const TOPIC: &str = "echo-test"; +const MAX_RECORDS: u8 = 10; -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. +#[async_std::main] +async fn main() -> Result<(), Box> { + 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 +``` + +[Install Fluvio CLI]: https://www.fluvio.io/cli/ From 24f2bd7181ca42f14736497ca4d7c42bd6c1b7d2 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 14:53:03 -0400 Subject: [PATCH 2/8] feat: use crate readme for docs --- crates/fluvio/src/lib.rs | 84 +--------------------------------------- 1 file changed, 2 insertions(+), 82 deletions(-) diff --git a/crates/fluvio/src/lib.rs b/crates/fluvio/src/lib.rs index de6eedfd81..a7d4c30fee 100644 --- a/crates/fluvio/src/lib.rs +++ b/crates/fluvio/src/lib.rs @@ -1,85 +1,5 @@ -//! The Rust client library for writing streaming applications with Fluvio -//! -//! Fluvio is a high performance, low latency data streaming platform built for developers. -//! -//! When writing streaming applications, two of your core behaviors are producing messages -//! and consuming messages. When you produce a message, you send it to a Fluvio cluster -//! where it is recorded and saved for later usage. When you consume a message, you are -//! reading a previously-stored message from that same Fluvio cluster. Let's get started -//! with a quick example where we produce and consume some messages. -//! -//! # Examples -//! -//! Fluvio's documentation provide a set of examples for Rust. -//! You can visit the examples page [following this link](https://www.fluvio.io/api/official/rust/examples/). -//! -//! # Fluvio Echo -//! -//! The easiest way to see Fluvio in action is to produce some messages and to consume -//! them right away. In this sense, we can use Fluvio to make an "echo service". -//! -//! All messages in Fluvio are sent in a sort of category called a `Topic`. You can think -//! of a Topic as a named folder where you want to store some files, which would be your -//! messages. If you're familiar with relational databases, you can think of a Topic as -//! being similar to a database table, but for streaming. -//! -//! As the application developer, you get to decide what Topics you create and which -//! messages you send to them. We need to set up a Topic before running our code. For the -//! echo example, we'll call our topic `echo`. -//! -//! # Example -//! -//! The easiest way to create a Fluvio Topic is by using the [Fluvio CLI]. -//! -//! ```bash -//! $ fluvio topic create echo -//! topic "echo" created -//! ``` -//! -//! There are convenience methods that let you get up-and-started quickly using default -//! configurations. Later if you want to customize your setup, you can directly use the -//! [`Fluvio`] client object. -//! -//! ```no_run -//! # mod futures { -//! # pub use futures_util::stream::StreamExt; -//! # } -//! use std::time::Duration; -//! use fluvio::{Offset, FluvioError, RecordKey}; -//! use futures::StreamExt; -//! -//! async_std::task::spawn(produce_records()); -//! if let Err(e) = async_std::task::block_on(consume_records()) { -//! println!("Error: {}", e); -//! } -//! -//! async fn produce_records() -> anyhow::Result<()> { -//! let producer = fluvio::producer("echo").await?; -//! for i in 0..10u8 { -//! producer.send(RecordKey::NULL, format!("Hello, Fluvio {}!", i)).await?; -//! async_std::task::sleep(Duration::from_secs(1)).await; -//! } -//! // fluvio batches records by default, so call flush() when done producing to ensure all -//! // records are sent -//! producer.flush().await?; -//! Ok(()) -//! } -//! -//! async fn consume_records() -> anyhow::Result<()> { -//! let consumer = fluvio::consumer("echo", 0).await?; -//! let mut stream = consumer.stream(Offset::beginning()).await?; -//! -//! while let Some(Ok(record)) = stream.next().await { -//! let key_str = record.get_key().map(|key| key.as_utf8_lossy_string()); -//! let value_str = record.get_value().as_utf8_lossy_string(); -//! println!("Got record: key={:?}, value={}", key_str, value_str); -//! } -//! Ok(()) -//! } -//! ``` -//! -//! [Fluvio CLI]: https://nightly.fluvio.io/docs/cli/ -//! [`Fluvio`]: ./struct.Fluvio.html +#[doc = include_str!("../README.md")] + #![cfg_attr( feature = "nightly", doc(include = "../../../website/kubernetes/INSTALL.md") From 6ca5af0ebf128b0022c1a99f518721a312891e6f Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 15:06:06 -0400 Subject: [PATCH 3/8] feat: rearrange --- crates/fluvio/README.md | 16 +++++++++++++++- crates/fluvio/src/lib.rs | 20 +++++++++++--------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/crates/fluvio/README.md b/crates/fluvio/README.md index 30e7e8aa8c..8a2cf205c0 100644 --- a/crates/fluvio/README.md +++ b/crates/fluvio/README.md @@ -1,4 +1,18 @@ -# Fluvio +
+

Fluvio

+ + The programmable data streaming platform + +
+ +
+ [![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) +
# Getting Started diff --git a/crates/fluvio/src/lib.rs b/crates/fluvio/src/lib.rs index a7d4c30fee..e121968485 100644 --- a/crates/fluvio/src/lib.rs +++ b/crates/fluvio/src/lib.rs @@ -1,23 +1,22 @@ -#[doc = include_str!("../README.md")] - #![cfg_attr( feature = "nightly", doc(include = "../../../website/kubernetes/INSTALL.md") )] -mod error; +#[doc = include_str!("../README.md")] + mod admin; +mod error; mod fluvio; -pub mod consumer; -mod producer; mod offset; +mod producer; mod sync; -pub mod spu; -pub mod metrics; + pub mod config; +pub mod consumer; +pub mod metrics; +pub mod spu; -use fluvio_types::PartitionId; -use tracing::instrument; pub use error::FluvioError; pub use config::FluvioConfig; pub use producer::{ @@ -42,6 +41,9 @@ pub use crate::fluvio::Fluvio; pub use fluvio_compression::Compression; +use fluvio_types::PartitionId; +use tracing::instrument; + /// The minimum VERSION of the Fluvio Platform that this client is compatible with. const MINIMUM_PLATFORM_VERSION: &str = "0.9.0"; From 5aa760dc061ac1e74f6f10de985b3003b2e87ecd Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 16:04:12 -0400 Subject: [PATCH 4/8] feat: relevant links --- crates/fluvio/README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/crates/fluvio/README.md b/crates/fluvio/README.md index 8a2cf205c0..95c7318956 100644 --- a/crates/fluvio/README.md +++ b/crates/fluvio/README.md @@ -14,7 +14,19 @@ [![Fluvio Discord](https://img.shields.io/discord/695712741381636168.svg?logo=discord&style=flat)](https://discordapp.com/invite/bBG2dTz) -# Getting Started +## What's Fluvio? + +Fluvio is a programmable data streaming platform written in Rust. With Fluvio +you can create performant real time applications that scale. + +Read more about Fluvio in the [official website][Fluvio.io]. + +## Getting Started + +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. 1. Install [Fluvio CLI][Install Fluvio CLI] if you havent already @@ -108,4 +120,17 @@ 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/ From ed82e212979230cdc1a0f05ae3f73913b2cc61e0 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 16:10:59 -0400 Subject: [PATCH 5/8] feat: use readme option --- crates/fluvio/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/fluvio/Cargo.toml b/crates/fluvio/Cargo.toml index 2f4049d1a8..3d822a8dbc 100644 --- a/crates/fluvio/Cargo.toml +++ b/crates/fluvio/Cargo.toml @@ -8,6 +8,7 @@ categories = ["database"] keywords = ["streaming", "stream", "queue"] repository = "https://github.com/infinyon/fluvio" description = "The official Fluvio driver for Rust" +readme = "README.md" [lib] name = "fluvio" From 9ae631ddc82de8f0b5c5d1fd9b59c6591e6b58d1 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 16:15:00 -0400 Subject: [PATCH 6/8] fix: labels renderization --- crates/fluvio/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/fluvio/README.md b/crates/fluvio/README.md index 95c7318956..82ab00ce0a 100644 --- a/crates/fluvio/README.md +++ b/crates/fluvio/README.md @@ -6,12 +6,14 @@
+ [![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) +
## What's Fluvio? From 1625c3476b88fd8a87a19c5e10c582aa3c84ad0e Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 16:59:31 -0400 Subject: [PATCH 7/8] Update README.md --- crates/fluvio/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fluvio/README.md b/crates/fluvio/README.md index 82ab00ce0a..5a5897cfb3 100644 --- a/crates/fluvio/README.md +++ b/crates/fluvio/README.md @@ -48,7 +48,7 @@ cargo add async-std --features attributes 4. Copy and paste the following snippet into your `src/main.rs` -```rust +```ignore use std::time::Duration; use fluvio::{Offset, RecordKey}; From e4122cedc5645efa129f8cabd5a62434b2bf4193 Mon Sep 17 00:00:00 2001 From: Esteban Borai Date: Wed, 31 May 2023 18:05:06 -0400 Subject: [PATCH 8/8] Update Cargo.toml --- crates/fluvio/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fluvio/Cargo.toml b/crates/fluvio/Cargo.toml index 3d822a8dbc..b16965e407 100644 --- a/crates/fluvio/Cargo.toml +++ b/crates/fluvio/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fluvio" -version = "0.19.1" +version = "0.19.2" edition = "2021" license = "Apache-2.0" authors = ["Fluvio Contributors "]