Brief intro to Riff is For Functions
In this example, we will explore the steps for deploying and scaling functions using project Riff, the function-as-a-service platform from Pivotal. This post begins with a brief overview of the Riff FaaS platform components as well as a demo scenario for getting us used to deploying and utilizing the environment.
Riff lets the developer write functions that respond to events. Functions are deployed as Kubernetes pods that contains a language-specific invoker for your custom function, and I/O bound sidecar for getting data in and out of the function scope. The sidecar has the responsibility of reading/writing messaging topics and dispatching the invoker with arguments.
Riff uses Custom Resource Definitions to enumerate functions and topics within kubernetes. In addition, it deploys a pair of controller pods to govern these resources — Topic and Function Controllers. The Topic Controller takes care of topic state changes with the underlying event broker. And the Function controller listens to topical events and manages function deployment, destruction, and scaling needs.
Messaging topics are configured from the function side, and must establish a named pair for input and output. Events received on the input topic get forwarded as parameters to your function, while the output topic receives the function output. If your function does not specify an output topic, then by default Riff will send it’s output to a topic of the same name as the function.
Riff employs an HTTP-gateway that lets you get data in and out of topics. Thus, there are 2 modes of communication: fire-and-forget (send some messages to a topic), and request/response — send message and await a reply. To talk to your function by HTTP command, the following conventions apply:
To get data into a topic only (fire-and-forget)
To get data into, and then await it’s output (request/response)
As discussed earlier Riff utilizes a functional invoker that will do all of the groundwork of calling our function code. Currently (as of February 2018), Riff supports 4 language environments: Java, Node.js, python, and shell. Note that function invokers will be made extensible in future versions, so that you may deploy ANY other (like Ruby, Perl and PHP) language as a function.
Riff presents a very powerful set of features to expose and manage functions. With this tool, you may enjoy exploring new app designs, and accelerating app delivery. The demo source code complements this introduction with new environment setup and use case deployment. Stay up to date with Riff development and checkout the project Riff homepage for more to come!