nats

package module
v0.0.0-...-097570e Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 7 Imported by: 0

README

Nats Trigger

This trigger subscribes to a topic on Nats (nats.io) server and listens for the messages.

Flogo CLI
flogo install github.com/s0rbus/flogo-components/trigger/nats

Configuration

Setting :
Name Type Description
host string host of nats server - REQUIRED
port int port of nats server - REQUIRED
HandlerSettings:
Name Type Description
topic string The Nats topic on which to listen for messages
Output:
Name Type Description
message string The message that was consumed

Examples

{
  "triggers": [
    {
      "id": "flogo-nats",
      "ref": "github.com/s0rbus/flogo-components/trigger/nats",
      "settings": {
        "host" : "localhost",
        "port" : 4442 
      },
      "handlers": [
        {
          "settings": {
            "topic": "syslog",
          },
          "action": {
            "ref": "github.com/project-flogo/flow",
            "settings": {
              "flowURI": "res://flow:my_flow"
            }
          }
        }
      ]
    }
  ]
}

Development

Testing

To be done.....

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
}

func (*Factory) Metadata

func (f *Factory) Metadata() *trigger.Metadata

func (*Factory) New

func (*Factory) New(config *trigger.Config) (trigger.Trigger, error)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewNatsHandler

func NewNatsHandler(logger log.Logger, handler trigger.Handler, nc *nats.Conn) (*Handler, error)

NewNatsHandler creates a new nats handler to handle a topic

func (*Handler) Start

func (h *Handler) Start() error

Start starts the handler

func (*Handler) Stop

func (h *Handler) Stop() error

Stop stops the handler

type HandlerSettings

type HandlerSettings struct {
	Topic string `md:"topic,required"`
}

type Output

type Output struct {
	Message string `md:"message"`
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Settings

type Settings struct {
	Host string `md:"host,required"`
	Port int    `md:"port,required"`
}

type Subscriber

type Subscriber struct {
	// contains filtered or unexported fields
}

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

func (*Trigger) Initialize

func (t *Trigger) Initialize(ctx trigger.InitContext) error

func (*Trigger) Metadata

func (t *Trigger) Metadata() *trigger.Metadata

Metadata implements trigger.Trigger.Metadata

func (*Trigger) Start

func (t *Trigger) Start() error

Start implements util.Managed.Start

func (*Trigger) Stop

func (t *Trigger) Stop() error

Stop implements util.Managed.Stop

Jump to

Keyboard shortcuts

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