runtime

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Overview

Package runtime contains functionality for runtime information of a plugin.

Index

Constants

View Source
const (
	// DefaultClusterID ...
	DefaultClusterID = "autobot"
	// DefaultClusterURL ...
	DefaultClusterURL = "nats://localhost:4222"
	// DefaultClusterInbox ...
	DefaultClusterInbox = "autobot.inbox"
	// DefaultClusterOutbox ...
	DefaultClusterOutbox = "autobot.outbox"
	// DefaultLogFormat ...
	DefaultLogFormat = "text"
	// DefaultLogLevel ...
	DefaultLogLevel = "warn"
)

Variables

View Source
var (
	// ErrNoRuntimeFunc signals that no functions have been configured to be run
	ErrNoRuntimeFunc = errors.New("runtime: no runtime functions have been configured")
)

Functions

func OnInitialize

func OnInitialize(y ...func())

OnInitialize sets the passed functions to be run when runtime is called for initialization.

Types

type Environment

type Environment struct {
	ClusterID  string `mapstructure:"cluster_id"`
	ClusterURL string `mapstructure:"cluster_url"`
	Debug      bool
	Inbox      string
	LogFormat  string `mapstructure:"log_format"`
	LogLevel   string `mapstructure:"log_level"`
	Name       string
	Outbox     string
	Verbose    bool
}

Environment describes a runtime environment for a plugin. This contains information about the used NATS cluster, the cluster id and the topic for plugin discovery.

func Env

func Env() *Environment

Env returns the current configured runtime environment.

type Runtime

type Runtime struct {
	Run  func(*Environment)
	RunE func(*Environment) error
}

Runtime is a plugin runtime that executes runtime functions

func NewRuntime

func NewRuntime() *Runtime

NewRuntime is returning a new Runtime

func (*Runtime) Execute

func (r *Runtime) Execute() error

Execute is running the configured runtime functions. It checks if there are functions configured and executes them with the configured environment. The initializer functions are run before the execution.

Jump to

Keyboard shortcuts

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