operation

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: BSD-3-Clause Imports: 5 Imported by: 82

README

Operation.

This library contains the interfaces to help develop Operations for CML.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(ref string) log.Logger

GetLogger gets activity logger by ref

func GetRef

func GetRef(operation Operation) string

func Register

func Register(operation Operation, f ...Factory) error

Register function registers Operation and it's Factory function.

Types

type Config

type Config struct {
	Operation string                 `json:"operation"`
	Params    map[string]interface{} `json:"params,omitempty"`
	Input     map[string]interface{} `json:"input,omitempty"`
	Output    string                 `json:"output,required"`
}

The struct config of operation.

type Factory

type Factory func(ctx InitContext) (Operation, error)

func GetFactory

func GetFactory(ref string) Factory

GetFactory gets activity factory by ref

type InitContext

type InitContext interface {

	// Params
	Params() map[string]interface{}

	// MapperFactory gets the mapper factory associated with the operation host
	MapperFactory() mapper.Factory

	// Logger logger to using during initialization, operation implementations should not
	// keep a reference to this
	Logger() log.Logger
}

type Operation

type Operation interface {
	Eval(inputs map[string]interface{}) (interface{}, error)
}

Activity is an interface for defining a custom Activity Execution

func Get

func Get(ref string) Operation

Get gets specified activity by ref

Jump to

Keyboard shortcuts

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