This Week in Fluvio #12
Welcome to This Week in Fluvio, our weekly newsletter for development updates to Fluvio open source. Fluvio is a distributed, programmable streaming platform written in Rust.
This is an addition to last week’s release of ArrayMap. We have some new examples.
- ArrayMap w/ JSON array inputs
- ArrayMap w/ JSON object inputs
- ArrayMap example code from our previous blog post
Prior to this release, trying to use invalid SmartStream code (but valid Rust code) with a consumer would result in the stream closing without a specific reason being reported to the user.
A user can compile their own SmartStream code, but if they forget to decorate their function with the #[smartstream]
attribute, it will still compile because it is valid Rust. However, not all valid Rust code is valid SmartStream code.
Example invalid SmartStream code:
use fluvio_smartstream::{Record, Result};
// Note the missing #[smartstream] attribute that should be here!
pub fn filter(record: &Record) -> Result<bool> {
let string = std::str::from_utf8(record.value.as_ref())?;
Ok(string.contains('a'))
}
Previous experience using the invalid SmartStream filter:
$ fluvio consume fruits --tail --filter=crates/fluvio-smartstream/examples/target/wasm32-unknown-unknown/debug/fluvio_wasm_filter.wasm
Consuming records starting 10 from the end of topic 'fruits'
Consumer stream has closed
Now, if a user tries to use incorrectly compiled SmartStream code they will receive an error message.
$ fluvio consume fruits --tail --filter=crates/fluvio-smartstream/examples/target/wasm32-unknown-unknown/debug/fluvio_wasm_filter.wasm
Consuming records starting 10 from the end of topic 'fruits'
Error:
0: Fluvio client error
1: SmartStream error
2: WASM module is not a valid 'filter' SmartStream. Are you missing a #[smartstream(filter)] attribute?
Get in touch with us on Github Discussions or join our Discord channel and come say hello!
For the full list of changes this week, be sure to check out our CHANGELOG.
Until next week!