README
¶
Command Function Invoker 
Purpose
The command function invoker provides a Docker base layer for a function consisting of a single command. It accepts gRPC requests, invokes the command for each request in the input stream, and sends the command's output to the stream of gRPC responses.
Install as a riff invoker
riff invokers apply -f command-invoker.yaml
Development
Prerequisites
The following tools are required to build this project:
make
- Docker
- Glide for dependency management
If you intend to re-generate mocks for testing, install:
If you would like to run tests using the ginkgo
command, install:
If you need to re-compile the protobuf protocol, install:
- Google's protocol compiler
Get the source
cd $(go env GOPATH) #defaults to ~/go
git clone -o upstream https://github.com/projectriff/command-function-invoker src/github.com/projectriff/command-function-invoker
Building
To build locally (this will produce a binary named command-function-invoker
on your machine):
make build
To build the Docker base layer:
make dockerize
This assumes that your docker client is correctly configured to target the daemon where you want the image built.
To run tests:
make test
To attach a delve capable debugger (such as Goland)
to a command-function-invoker
running inside k8s:
make debug-dockerize
Then expose the 2345
port as a service, using riff/config/delve/command-function-invoker-debug.yaml
:
riff invokers apply -f riff/config/delve/command-function-invoker-debug.yaml
Finally, update the function you would like to debug so that it picks up the new base layer.
Then you can connect the debugger through port 30110
.
Compiling the Protocol
The gRPC protocol for the command function invoker is defined in function.proto.
Clone https://github.com/projectriff/function-proto and set $FN_PROTO_PATH
to point at the cloned directory. Then issue:
make gen-proto
riff Commands
riff init command
Initialize a command function
Synopsis
Generate the function based on the executable command specified as the filename, using the name and version specified for the function image repository and tag.
For example, from a directory named 'echo' containing a function 'echo.sh', you can simply type :
riff init command -a echo.sh
to generate the resource definitions using sensible defaults.
riff init command [flags]
Options
-h, --help help for command
Options inherited from parent commands
-a, --artifact string path to the function artifact, source code or jar file
--config string config file (default is $HOME/.riff.yaml)
--dry-run print generated function artifacts content to stdout only
-f, --filepath string path or directory used for the function resources (defaults to the current directory)
--force overwrite existing functions artifacts
-i, --input string the name of the input topic (defaults to function name)
--invoker-version string the version of the invoker to use when building containers
-n, --name string the name of the function (defaults to the name of the current directory)
-o, --output string the name of the output topic (optional)
-u, --useraccount string the Docker user account to be used for the image repository (default "current OS user")
-v, --version string the version of the function image (default "0.0.1")
SEE ALSO
- riff init - Initialize a function
riff create command
Create a command function
Synopsis
Create the function based on the executable command specified as the filename, using the name and version specified for the function image repository and tag.
For example, from a directory named 'echo' containing a function 'echo.sh', you can simply type :
riff create command -a echo.sh
to create the resource definitions, and apply the resources, using sensible defaults.
riff create command [flags]
Options
-h, --help help for command
--namespace string the namespace used for the deployed resources (defaults to kubectl's default)
--push push the image to Docker registry
Options inherited from parent commands
-a, --artifact string path to the function artifact, source code or jar file
--config string config file (default is $HOME/.riff.yaml)
--dry-run print generated function artifacts content to stdout only
-f, --filepath string path or directory used for the function resources (defaults to the current directory)
--force overwrite existing functions artifacts
-i, --input string the name of the input topic (defaults to function name)
--invoker-version string the version of the invoker to use when building containers
-n, --name string the name of the function (defaults to the name of the current directory)
-o, --output string the name of the output topic (optional)
-u, --useraccount string the Docker user account to be used for the image repository (default "current OS user")
-v, --version string the version of the function image (default "0.0.1")
SEE ALSO
- riff create - Create a function (equivalent to init, build, apply)