riff is for functions

riff is for functions

  • Docs
  • Blog
  • GitHub
  • Slack

›Function Invokers

Version (v0.5.x)

  • v0.6.x (snapshot)
  • v0.4.x
  • v0.3.x

Getting Started

  • Pick your environment
  • GKE
  • Minikube
  • Docker for Mac
  • Docker for Windows

Runtimes

  • Core
  • Knative
  • Streaming

Function Invokers

  • Java
  • Node.js
  • Command

CLI Reference

  • riff
  • riff doctor
  • riff completion
  • Credential

    • riff credential
    • riff credential apply
    • riff credential delete
    • riff credential list

    Build

    • riff function
    • riff function create
    • riff function delete
    • riff function list
    • riff function status
    • riff function tail
    • riff application
    • riff application create
    • riff application delete
    • riff application list
    • riff application status
    • riff application tail
    • riff container
    • riff container create
    • riff container delete
    • riff container list
    • riff container status

    Knative Runtime

    • riff knative
    • riff knative adapter
    • riff knative adapter create
    • riff knative adapter delete
    • riff knative adapter list
    • riff knative adapter status
    • riff knative deployer
    • riff knative deployer create
    • riff knative deployer delete
    • riff knative deployer list
    • riff knative deployer status
    • riff knative deployer tail

    Core Runtime

    • riff core
    • riff core deployer
    • riff core deployer create
    • riff core deployer delete
    • riff core deployer list
    • riff core deployer status
    • riff core deployer tail

    Streaming Runtime

    • riff streaming
    • riff streaming stream
    • riff streaming stream create
    • riff streaming stream delete
    • riff streaming stream list
    • riff streaming stream status
    • riff streaming processor
    • riff streaming processor create
    • riff streaming processor delete
    • riff streaming processor list
    • riff streaming processor status
    • riff streaming processor tail
    • riff streaming gateway
    • riff streaming gateway list
    • riff streaming gateway status

    In-memory Gateway

    • inmemory-gateway
    • inmemory-gateway create
    • inmemory-gateway delete
    • inmemory-gateway list
    • inmemory-gateway status

    Kafka Gateway

    • kafka-gateway
    • kafka-gateway create
    • kafka-gateway delete
    • kafka-gateway list
    • kafka-gateway status

    Pulsar Gateway

    • pulsar-gateway
    • pulsar-gateway create
    • pulsar-gateway delete
    • pulsar-gateway list
    • pulsar-gateway status
Edit

Command Function Invoker

Command functions are invoked using a Command Function Invoker that is provided by riff when building the function.

The command function invoker provides a host for functions implemented as a single executable command (be it a shell script or a binary). It accepts HTTP requests and invokes the command for each request.

Communication with the function is done via stdin and stdout. Functions can log by writing to stderr.

For each invocation, functions are expected to read stdin until the end of the stream (EOF) and provide a result on stdout.

Correct function execution is assumed if the exit code is zero. Any other value indicates an error.

Authoring a function

This example uses the sample command-wordcount function from projectriff-samples on GitHub. It consists of a single executable file named wordcount.sh with the following content:

#!/bin/bash

tr [:punct:] ' ' | tr -s ' ' '\n' | tr [:upper:] [:lower:] | sort | uniq -c | sort -n

Then set the execute bit to make the function executable.

chmod +x wordcount.sh

NOTE: If creating a command function on Windows then the the execute bit cannot be set on the local file. Before committing the function file to a Git repository it must have the execute bit set using the following Git command: git update-index --chmod=+x wordcount.sh.

Creating a function

Function can either be built from local source or from source committed to a Git repository.

build from local source

NOTE: The --local-path builds option is disabled on Windows.

For local build use:

riff function create wordcount --artifact wordcount.sh --local-path .

build from git repository

When building from a Git repo use something like the example below and replace the --git-repo value with the new repository URL.

For building from a Git repository use:

riff function create wordcount --artifact wordcount.sh --git-repo https://github.com/projectriff-samples/command-wordcount

Deploying a function

Please see the runtime documentation for how to deploy and invoke the function.

  • Core runtime
  • Knative runtime

Cleanup

When done with the function, delete the function resource to stop creating new builds.

NOTE: Images built by the function continue to exist in the container registry and may continue to be consumed by a runtime.

riff function delete wordcount
Deleted function "wordcount"
← Node.jsriff →
  • Authoring a function
  • Creating a function
    • build from local source
    • build from git repository
  • Deploying a function
  • Cleanup
riff is for functions
Docs
Versions
Community
BlogGitHubSlackKnativeTwitter
More
Privacy PolicyTerms of UseCode of Conduct
Deployed by Netlify
Copyright © 2021 VMware, Inc