Skip to content

lionelvillard/knative-functions

Repository files navigation

Knative Eventing Functions

Build Status

This project provides a collection of functions manipulating Cloud Events.

All functions are currently only callable (synchronous). We are planning to add composable (asynchronous) functions the near future.

Installation

You first need to install the Knative Eventing Function Controller:

kubectl apply -f https://github.com/lionelvillard/knative-functions-controller/releases/download/v0.1.2/function.yaml

Then install the function library:

kubectl apply -f https://github.com/lionelvillard/knative-functions/releases/download/v0.2.0/functions.yaml

Functions

The functions are:

Wait

The Wait function forward events after X seconds.

Example

apiVersion: functions.knative.dev/v1alpha1
kind: Wait
metadata:
  name: wait-5
spec:
  seconds: 5

Filter

A filter takes a cloud event as input, evaluates a predicate against it and returns the unmodified event when the predicate return true, otherwise returns an empty response.

The predicate must be a Javascript expression. It is evaluated in a sandbox with the variable event

Example

apiVersion: functions.knative.dev/v1alpha1
kind: Filter
metadata:
  name: filter
spec:
  expression: event.data.assigned