This project is an unofficial connector/trigger for OpenFaaS, which allows triggering deployed function from RabbitMQ.
It leverages Routing keys
for which OpenFaaS functions can be registered. More on the usage can be read here.
Using the OpenFaaS CLI or Rest API
deploy a function which has an annotation
named topic
, this has to be a comma-separated string of the relevant topics.
E.g. log,monitoring,billing
. Please also make sure to check out the official Rabbit MQ documentation here and here
in order to avoid message dropping. The connector is configured to spawn workers per topic based on the available CPU's,
however it will try to spawn at least 1 worker per topic. Currently, the connector operates on 1 exchange and leverage 1
Queue. Information on the Topology of the Queue can be found here
-
basic_auth
: Toggle to activate or deactivate basic_auth (E.g1
||true
) -
secret_mount_path
: The path to a file containing the basic auth secret for the OpenFaaS gateway -
OPEN_FAAS_GW_URL
: URL to the OpenFaaS gateway defaults tohttp://gateway:8080
-
RMQ_TOPICS
: Rabbit MQ Topics which are relevant in an comma separated list. E.g.billing,account,support
-
RMQ_HOST
: Hostname/ip of Rabbit MQ -
RMQ_PORT
: Port of Rabbit MQ -
RMQ_USER
: Defaults toguest
-
RMQ_PASS
: Defaults toguest
-
RMQ_QUEUE
: Queue Name will default toOpenFaasQueue
-
RMQ_EXCHANGE
: Exchange Name will default toOpenFaasEx
-
REQ_TIMEOUT
: Request Timeout for invocations of OpenFaaS functions defaults to30s
-
TOPIC_MAP_REFRESH_TIME
: Refresh time for the topic map defaults to60s
-
INSECURE_SKIP_VERIFY
: Allows to skip verification of HTTP Cert for Communication Connector <=> OpenFaaS default isfalse
. It is recommended to keep false, as enabling it opens up the possibility of a man in the middle attack.
1 Exchange (set via RMQ_EXCHANGE
) & N Topic (set per topic with naming schema OpenFaaS_TOPIC
)
Exchange:
Kind: "direct",
Durable: true,
Auto Delete: false,
Internal: false,
No Wait: false
Queue:
Durable: true,
Auto Delete: false,
Internal: false,
No Wait: false
The required files to deploy OpenFaaS RabbitMQ connector can be found under artifacts
. It assumes that OpenFaaS was
deployed as described here. The default config is
setup to work with OpenFaaS as described there. Further within connector-cfg.yaml there
are values that need to be override with your Rabbit MQ setup, they are marked with replace_me
.
The required file to deploy OpenFaaS RabbitMQ connector can be found under artifacts
. It assumes that OpenFaaS was
deployed using this script. The docker-compose.yml ships with an
RabbitMQ node and an producer, you might want to remove them. If you want to use an existing Rabbit MQ setup make sure to
override RMQ
accordingly.
- Start an local Rabbit MQ Broker, this can be done with
/hack/development_env_setup.sh
. - Expose the necessary environment variables, in GoLand this can be done as part of the configuration
- Deploy at least one function that listens to a topic:
$ faas-cli store deploy figlet --annotation topic="account"
- Start a producer to generate messages
Please feel free to report any issues or Feature request on the Issue Tab.