Categorygithub.com/konstellation-io/kre-runners/kre-go/v4
modulepackage
4.5.1
Repository: https://github.com/konstellation-io/kre-runners.git
Documentation: pkg.go.dev

# README

KRE Golang Runner

This is an implementation in Go for the KRE runner.

How it works

The Go runner is one of the two types of runners that can be used in a KRE workflow and allows executing go code.

Once the go runner is deployed, it connects to NATS and subscribes permanently to an input subject. Each node knows to which subject it has to subscribe and also to which subject it has to send messages, since the K8s manager tells it with environment variables. It's important to note that the nodes use a queue subscription, which allows load balancing of messages when there are multiple replicas of the runner.

When a new message is published in the input subject of a node, the runner passes it down to a handler function, along with a context object formed by variables and useful methods for processing data. This handler is the solution implemented by the client and given in the krt file generated. Once executed, the result will be taken by the runner and transformed into a NATS message that will then be published to the next node's subject (indicated by an environment variable). After that, the node ACKs the message manually.

Requirements

It is necessary to set the following environment variables in order to use the runner:

NameDescription
KRT_WORKFLOW_NAMEName of the current workflow
KRT_VERSION_IDID of the current version
KRT_VERSIONName of the current version
KRT_NODE_NAMEName of the current node
KRT_NATS_SERVERNATS server URL
KRT_NATS_INPUTInput NATS subject to which the node will be subscribed
KRT_NATS_OUTPUTOutput NATS subject to which the node will publish the next message
KRT_NATS_STREAMNATS stream name
KRT_NATS_MONGO_WRITERMongo writer name
KRT_BASE_PATHBase path where the src folder is located
KRT_HANDLER_PATHPath to the handler file
KRT_MONGO_URIMongo database URI
KRT_INFLUX_URIInflux database URI

Run Tests

Execute the test running:

go test

Integration tests have been migrated to the e2e folder.

# Packages

No description provided by the author
Package mocks is a generated GoMock package.
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewRunner creates a new Runner instance, initializing a new handler context within and runs the given handler init func.
Start receives the handler init function and the handler function connects to NATS and MongoDB and processes all incoming messages.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
Enum value maps for MessageType.
Enum value maps for MessageType.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

Handler is the function executed each time a message from NATS arrives.
HandlerInit is executed once.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author