nats-consume

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

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README


{ "image": "direktiv/nats-consume", "desc": "Consumes messages from a NATS Service" }

NATS

Consumes messages from a NATS Service

Direktiv

An example workflow of consuming from a NATS service.

id: nats
functions:
- id: nats-consume
  image: direktiv/nats-consume:v1
description: "Read messages from a NATS service"
states:
- id: natsread
  type: action
  action:
    function: nats-consume
    input: jq(.)

Input

Writes a message to the NATS service hosted on the address. The fields username and password are optional fields used for user authentication.

The property timeout is optional(default=1000) and is the amount of time in milliseconds to consume messages.

The property max-messages is optional(default=10) and is the amount of messages to wait to be consumed.

This app will consume messages until either the max-messages are consumed or the timeout is reached.

input:
  address: "localhost:4222"
  username: "test"
  password: "test"
  subject: "direktiv"
  timeout: 1000
  "max-messages": 10

Output

If the output is successful, the messages consumed will be returned as a string array.

{
	"return": {
		"messages": [
			"Hello World :)!",
			"Goodbye"
		]
	}
}

Error

In the case that an error is encountered, it will present in the following format:

{
    "errorCode": "com.nats-consume.error",
    "errorMsg": "Something went wrong"
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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