function

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 4 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(name string, creator Creator)

Add should be called in init func of an implementing Function.

func RegisteredFunctions

func RegisteredFunctions() []string

RegisteredFunctions returns a slice of the names of every function registered.

Types

type Creator

type Creator func() Function

Creator defines the init structure for a Function.

type ErrNotFound

type ErrNotFound struct {
	Name string
}

ErrNotFound gives the details of the failed function

func (ErrNotFound) Error

func (a ErrNotFound) Error() string

type Function

type Function interface {
	Apply(message.Msg) (message.Msg, error)
}

Function has a single defined function to serve the purpose of apply logic to a message in order to return a message.

func GetFunction

func GetFunction(name string, conf map[string]interface{}) (Function, error)

GetFunction looks up a function by name and then init's it with the provided map. returns ErrNotFound if the provided name was not registered.

type Mock

type Mock struct {
	ApplyCount int
	Err        error
}

Mock can be used in tests to track whether Function.Apply was called and test for expected errors.

func (*Mock) Apply

func (m *Mock) Apply(msg message.Msg) (message.Msg, error)

Apply fulfills the Function interface for use in tests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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