Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


build Go Report Card GoDoc License: MIT OpenFaaS

An OpenFaaS event-connector to trigger functions from NATS Core pub/sub topics.

Is the nats-connector or JetStream for OpenFaaS right for you?

At most once QoS: Core NATS offers an at most once quality of service. If a subscriber is not listening on the subject (no subject match), or is not active when the message is sent, the message is not received. This is the same level of guarantee that TCP/IP provides. Core NATS is a fire-and-forget messaging system. It will only hold messages in memory and will never write messages directly to disk.

From the NATS docs

If no nats-connector is available at the time of a message being published, it will not be delivered to any functions. Likewise, if the function is unavailable or crashing, it will not receive the message. NATS Core has no durability.

For production and commercial use, see: JetStream for OpenFaaS

Quick start

Deploy the connector to faasd

See the eBook Serverless For Everyone Else for instructions and sample YAML to add to your faasd host.

Or deploy the connector to Kubernetes

  1. Deploy the connector using arkade

    arkade install nats-connector

    Alternatively, see the Helm chart

  2. Deploy the two test functions

    git clone --depth=1
    cd nats-connector/contrib/test-functions

    Deploy the functions using stack.yml, see how the receive-message function has the topic=nats-test annotation? That's how a function binds itself to a particular NATS Subject.

    faas-cli template pull stack
    faas-cli deploy
  3. Now publish a message on the nats-test topic.

    Invoke the publisher

    faas-cli invoke publish-message <<< "test message"
  4. Verify that the receiver was invoked by checking the logs

    faas-cli logs receive-message
    2019-12-29T19:06:50Z 2019/12/29 19:06:50 received "test message"


Configuration of the binary is by environment variable. The names vary for the values.yaml file in the Helm chart.

Variable Description Default
topics Delimited list of topics nats-test,
broker_host The host, but not the port for NATS nats
async_invocation Queue the invocation with the built-in OpenFaaS queue-worker and return immediately false
gateway_url The URL for the OpenFaaS gateway http://gateway:8080
upstream_timeout Timeout to wait for synchronous invocations 60s
rebuild_interval Interval at which to rebuild the map of topics <> functions 5s
topic_delimiter Used to separate items in topics variable ,