The OpenServerless streamer is a tool to relay a stream from OpenWhisk actions to an outside HTTP client.
The streamer is a simple HTTP server that exposes an endpoint /stream/{namespace}/{action} to invoke the relative OpenWhisk action, open a socket for the action to write to, and relay the output to the client.
It expects 2 environment variables to be set:
OW_APIHOST
: the OpenWhisk API hostSTREAMER_ADDR
: the address of the streamer server for the OpenWhisk actions to connect to
Other environment variables can be set to configure the streamer:
HTTP_SERVER_PORT
: the port the streamer server listens on (default: 80)
Cors handling is handled through these variables:
CORS_ENABLED
: set to 1 or true to enable the CORS handlerCORS_ALLOW_ORIGIN
: this defaults to*
CORS_ALLOW_METHODS
: this defaults toGET,POST,OPTIONS
CORS_ALLOW_HEADERS
: this defaults toAuthorization,Content-Type
The streamer exposes the following endpoints (use POST in case you need to send arguments to the action):
-
GET/POST /action/{namespace}/{action}
: to invoke the OpenWhisk action on the given namespace, default package, and action name. It requires an Authorization header with Bearer token with the OpenWhisk AUTH token. -
GET/POST /action/{namespace}/{package}/{action}
: to invoke the OpenWhisk action on the given namespace, custom package, and action name. It requires an Authorization header with Bearer token with the OpenWhisk AUTH token -
GET/POST /web/{namespace}/{action}
: to invoke an OpenWhisk web action on the given namespace, default package, and action name. -
GET/POST /web/{namespace}/{package}/{action}
: to invoke an OpenWhisk web action on the given namespace, custom package, and action name.
Taskfile supports the following tasks:
* build: Build the streamer binary locally. This will create a binary named streamer in the current directory.
* buildx: Build the docker image using buildx. Set PUSH=1 to push the image to the registry.
* clean: Clean up the build artifacts. This will remove the streamer binary and clean the go cache.
* docker-login: Login to the docker registry. Set REGISTRY=ghcr or REGISTRY=dockerhub in .env to use the respective registry.
* image-tag: Create a new tag for the current git commit.
* run: Run the streamer binary locally, using configuration from .env file
* test: Run the tests in the src directory.
To build an image and push it on a private repository, firstly choose which
registry you want to use.
Tasks support is for Github (ghcr) and Dockerhub (dockerhub).
So copy the .env.example
to .env
and configure the required variables for
authentication and set the REGISTRY
and NAMESPACE
accordly.
Now create a new tag
$ task image-tag
You should see an output like this:
Deleted tag '0.1.0-rc1-incubating.2504260711' (was 5a2f6d3)
0.1.0-rc1-incubating.2504260905
💡 NOTE If you leave unset REGISTRY
a local openserverless-streamer
image will be built, using the generated tag.
If you setup the REGISTRY
and NAMESPACE
, you can give a:
$ task docker-login
To build:
$ task buildx
To build and push
$ task buildx PUSH=1
To build an official Apache OpensSrverless Streamer image, you need to be a committer.
If you have the proper permissions, the build process will start pushing a
new tag to apache/openserverless-streamer repository.
So, for example, if your tag is 0.1.0-rc1-incubating.2504260905
and your
git remote is apache
$ git push apache 0.1.0-rc1-incubating.2504260905
This will trigger the build workflow, and the process will be visible at https://github.com/apache/openserverless-streamer/actions