Stateful Services (private release) Build composable event-driven data pipelines in minutes.

Request access

SSDK Command Line Interface

Stateful Services Developer Kit (ssdk) is a binary, shipped with fluvio, that helps developers build, test, and deploy stateful services. The first version works with Rust, and upcoming versions will enable Python and Javascript.

Commands

 

Download FVM and Install SSDK

Download fluvio version manager (fvm), the package manager for fluvio and ssdk:

$ curl -fsS https://hub.infinyon.cloud/install/install.sh | bash

This command will download the Fluvio Version Manager (fvm), Fluvio CLI (fluvio) and config files into $HOME/.fluvio, with the executables in $HOME/.fluvio/bin. To complete the installation, you will need to add the executables to your shell $PATH.

Install the preview release:

$ fvm install ssdk-preview6

SSDK has the following comamand hierarchy:

$ ssdk -h
Stateful Service Development Kit utility

Usage: ssdk <COMMAND>

Commands:
 build     Build Stateful Service
 clean     Clean generated files from service directory
 generate  Generate SSDK projects from data-pipeline.yaml
 update    Update SSDK project
 run       Run Stateful Service
 setup     Setup pre-requisites for Stateful Service
 version   Display version information
 log       Print data pipeline logs
 help      Print this message or the help of the given subcommand(s)
 

ssdk setup

Command line syntax for ssdk setup:

$ ssdk setup -h   
Setup pre-requisites for Stateful Service

Usage: ssdk setup

Run ssdk setup to configure your local environment.

$ ssdk setup
 

ssdk generate

Command line syntax for ssdk generate:

$ ssdk generate -h
Generate SSDK projects from data-pipeline.yaml

Usage: ssdk generate
 
Example

SSDK generate requires a data-pipeline.yaml the current directory:

$ ssdk generate

The command parses the file and creates a Rust project in a subdirectory called project. For additional information, check out Data Pipeline File.

 

ssdk build

Command line syntax for ssdk build:

$ ssdk build -h
Build Stateful Service

Usage: ssdk build
 
Example

The command builds the Rust project and generates all WASM Components.

$ ssdk build

Checkout the project directory to see the project hierarchy and the target components.

 

ssdk update

Command line syntax for ssdk update:

$ ssdk update -h
Update SSDK project

Usage: ssdk update [OPTIONS]

Options:
 -f, --force    force to apply all updates
 -d, --dry-run  print changes and exit

This command is used to update the project based on updated in the data-pipeline.yaml file.

The update command makes code changes that cannot be reversed. As a safety measure, the command generates a diff and asks for confirmation before proceeding. If you want to bypass the confirmation prompt, use the -f and -d flags.

 

ssdk clean

Command line syntax for ssdk clean:

$  ssdk clean -h
Clean generated files from project directory

Usage: ssdk clean

This command is used to clean-up the project directory and start again.

 
Example

Let’s say we made major changes to the data-pipeline.yaml file and the previous version is no longer relevant. We can use clean to remove the project and start over:

$ ssdk clean
 

ssdk log

Use ssdk log to view you print statements:

$  ssdk log -h
Print data pipeline logs

Usage: ssdk log [OPTIONS]

Options:
 -f, --follow  Specify if the logs should be streamed

Use --f --follow option to watch the logs.

 
Example

The following code splits sentences into words and has a println statement:

- operator: flat-map
  run: |
    fn split_sentence(sentence: String) -> Result<Vec<String>, String> {
      let result = sentence.split_whitespace().map(String::from).collect();
      println!("{:?}", result);

      Ok(result)
    }    

For the sentence with This is a test, the output will be:

$ ssdk log
2024-01-06T02:08:09.735861+00:00 split-sentence INFO ["This", "is", "a", "test"]
 

ssdk version

Command line syntax for ssdk version:

$ ssdk version -h
Display version information

Usage: ssdk version
 
Example

Find out what version you are running:

$ ssdk version
 

ssdk run

Run the project and open the command line in interactive mode with ssdk run:

$ ssdk run -h                                
Run Stateful Service

Usage: ssdk run [OPTIONS]

Options:
     --ui           start the workflow viewer ui [env: UI=]
 -p, --port <PORT>  port for web server to listen on [env: PORT=] [default: 8000]

Use --ui to view a graphical represetation of the project in a web browser. The default port is 8000, and you may change it with the --port flag.

 
Example

Navigate to the project directory, ensure it’s built, and run to start the project in interactive mode:

$ ssdk run --ui
Please visit http://127.0.0.1:8000 to use SSDK Studio
...
 

>> - interactive mode

SSDK run opens the command line in interactive mode:

>> -h
SSDK - Stateful Service Development Kit

Usage: <COMMAND>

Commands:
 show  Show or List states. Use `show state --help` for more info
 exit  Stop interactive session
 

>> show state

Use show state to peak into the internal state objects managed by the system:

Command line syntax for show state:

>> show state -h
List all states or show state for given key

Usage: show state [OPTIONS] [NAMESPACE]

Arguments:
 [NAMESPACE]  namespace of state

Options:
     --key <KEY>        key of state
     --filter <FILTER>  filter regex
 
Example

For example, to show all state objects:

>> show state
 Namespace                                     Keys  Type   
 word-processing-window/count-per-word/state   22    u32    
 word-processing-window/sentence/topic.offset  1     offset 

The states are organized by namespace where the first keyword is the service name word-processing-window, followed by the function name count-per-word or topic sentence. The state is the temporary result computed by the window function, whereas topic.offset is the offset of the last record read from the sentence topic.

To further inspect the objects, use the show state command with the name of the namespace:

>> show state word-processing-window/count-per-word/state
 Key       Value  Window                                    
 book      1      2023-12-28T00:32:00Z:2023-12-28T00:32:20Z 
 but       1      2023-12-28T00:32:00Z:2023-12-28T00:32:20Z 
...

You also have the option to filter the state by key (--key), or a regex (--filter) operation.

 

>> exit

Exit interactive mode:

>> exit
bye!
 

References