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: 5 Imported by: 0

README

NATS

This activity provides your Flogo app the ability to send a message to a NATS server

Installation

flogo install github.com/s0rbus/flogo-components/activity/nats

Link for flogo web:

https://github.com/s0rbus/flogo-components/activity/nats

Configuration

Settings:
Name Type Description
server string NATS server (format is servername:port) - REQUIRED
topic string topic on which to publish message - REQUIRED
Input
Name Type Description
message string The message to send

Example

The json below sends 'Hello from Flogo' to topic 'general' on a NATS server running on localhost

{
  "id": "publish_nats_message",
  "name": "Publish message to NATS",
  "activity": {
     "ref": "github.com/s0rbus/flogo-components/activity/nats",
     "settings": {
        "server" : "localhost:4222",
        "topic" : "general"
     },
     "input": {
        "message": "Hello from Flogo"
     }
  }
}

Development

Testing

To run tests first set up a NATS server using the docker-compose file given below:

version: '3.7'
services:
    server:
        image: nats
        container_name: natsio-server
        ports:
            - '4222:4222'
            - '8222:8222'

Then run the following command:

go test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New optional factory method, should be used if one activity instance per configuration is desired

Types

type Activity

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

Activity is a nats activity

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements api.Activity.Eval - Logs the Message

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata returns the activity's metadata

type Input

type Input struct {
	Message string `md:"message,required"`
}

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

type Settings

type Settings struct {
	Server string `md:"server,required"`
	Topic  string `md:"topic,required"`
}

Jump to

Keyboard shortcuts

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