SmartModules Quickstart
SmartModules are the basic building blocks for transformations in Fluvio, allowing users to define custom functions for processing or transforming streaming data. They provide a flexible way to tailor data handling to meet particular needs, enhancing Fluvio's capabilities.
Prerequisites
This tutorial assumes that Fluvio is installed. Follow the Fluvio - Quickstart to get set up. You can follow along using a local cluster, the webhook section however requires a Cloud cluster.
See list of available SmartModules
$ fluvio hub sm list
SMARTMODULE Visibility
infinyon/jolt@x.y.z public
infinyon/json-sql@x.y.z public
infinyon/regex-filter@x.y.z public
...
All versions are marked with x.y.z
in the docs. Please use the number returned by the fluvio hub sm list
command.
Download SmartModules
SmartModules must be downloaded before they can be used. Afterwards, downloaded SmartModules are available for your Producers and Consumers.
$ fluvio hub smartmodule download infinyon/regex-filter@x.y.z
downloading infinyon/regex-filter@x.y.z to infinyon-regex-filter-x.y.z.ipkg
... downloading complete
... checking package
trying connection to fluvio router.infinyon.cloud:9003
... cluster smartmodule install complete
Use SmartModule with Producer and Consumer
You can specify a SmartModule to use with fluvio produce
and fluvio consume
. Let's create a topic cats
:
$ fluvio topic create cats
$ fluvio produce cats
> cat
Ok!
> dog
Ok!
> Cat
This consumer is using the SmartModule we just downloaded with --smartmodule
, and is also configuring it with --params
/-e
.
$ fluvio consume -Bd --smartmodule infinyon/regex-filter@x.y.z --params regex='[Cc]at' cats
cats
Cats
The --transforms-file
flag are for more complex transformations defined in a YAML file. See the Transformation Chaining page for more detail.
Use Multiple Transformations
Smartmodules handle chained transformations via a transforms.yaml
file. Order matters here, so infinyon/jolt@x.y.z
is first and infinyon/regex-filter@x.y.z
is second.
transforms:
- uses: infinyon/jolt@x.y.z
with:
spec:
- operation: shift
spec:
fact: "animal.fact"
length: "length"
- uses: infinyon/regex-filter@x.y.z
with:
regex: "[Cc]at"
$ fluvio consume --transforms-file ./my-transforms.yaml cats
We'll leave this example as an exercise for the reader. Checkout Cloud Tutorials for additional examples.
See list of Downloaded SmartModules
$ fluvio smartmodule list
SMARTMODULE SIZE
infinyon/regex-filter@x.y.z 312.7 KB