nats-connector

command module
v0.0.0-...-fe3d2f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 6 Imported by: 0

README

nats-connector

Docker Build Status Go Report Card GoDoc OpenFaaS

An OpenFaaS event-connector to trigger functions from NATS.

Try it out

Test functions have been created to help you verify the installation of nats-connector. See contrib/test-functions.

Deploy on Kubernetes

The following instructions show how to run and test nats-connector on Kubernetes.

  1. Deploy the receiver functions, the receiver function must have the topic annotation:

    export OPENFAAS_URL="http://localhost:8080" # Set your gateway via env variable or the -g flag
    faas-cli deploy --name receive-message --image openfaas/receive-message:latest --fprocess='./handler' --annotation topic="nats-test"
    

    Or deploy with the stack.yml provided in this repo:

    cd contrib/test-functions
    faas-cli template pull stack
    faas-cli deploy --filter receive-message
    
  2. Deploy the connector with:

    kubectl apply -f ./yaml/kubernetes/connector-dep.yaml
    
  3. Deploy the publish-message function

    faas-cli deploy --name publish-message --image openfaas/publish-message:latest --fprocess='./handler' --env nats_url=nats://nats.openfaas:4222
    

    Or deploy via stack.yml

    cd contrib/test-functions
    faas-cli template pull stack
    faas-cli deploy --filter publish-message
    
  4. Now publish a message on the nats-test topic.

    Invoke the publisher

    faas-cli invoke publish-message <<< "test message"
    
  5. 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"
    

Building

Build and release is done via CI, but you can also build your own version locally.

export TAG=0.2.1
make build push
Configuration

Configuration is by environment variable, which can be set in the Kubernetes YAML file: yaml/kubernetes/connector-dep.yaml

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 ,

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL