operator

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 8 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is a global registry of operator types to operator builders.

Functions

func Lookup added in v0.12.2

func Lookup(configType string) (func() Builder, bool)

Lookup looks up a given config type, prioritizing builtin operators before looking in registered plugins. Its second return value will be false if no builder is registered for that type

func Register

func Register(operatorType string, newBuilder func() Builder)

Register will register an operator in the default registry

func RegisterPlugin added in v0.12.2

func RegisterPlugin(pluginName string, newBuilder func() Builder)

RegisterPlugin will register a plugin in the default registry

Types

type BuildContext

type BuildContext struct {
	Database         database.Database
	Parameters       map[string]interface{}
	Logger           *logger.Logger
	Namespace        string
	DefaultOutputIDs []string
	PluginDepth      int
}

BuildContext supplies contextual resources when building an operator.

func NewBuildContext added in v0.12.2

func NewBuildContext(db database.Database, lg *zap.SugaredLogger) BuildContext

NewBuildContext creates a new build context with the given database, logger, and the default namespace

func (BuildContext) Copy added in v0.12.2

func (bc BuildContext) Copy() BuildContext

Copy creates a copy of the build context

func (BuildContext) PrependNamespace added in v0.12.2

func (bc BuildContext) PrependNamespace(id string) string

PrependNamespace adds the current namespace of the build context to the front of the given ID if that ID is not already namespaced up to the root level

func (BuildContext) WithDefaultOutputIDs added in v0.12.2

func (bc BuildContext) WithDefaultOutputIDs(ids []string) BuildContext

WithDefaultOutputIDs sets the default output IDs for the current context or the current operator build

func (BuildContext) WithIncrementedDepth added in v0.12.2

func (bc BuildContext) WithIncrementedDepth() BuildContext

WithIncrementedDepth returns a new build context with an incremented plugin depth

func (BuildContext) WithSubNamespace added in v0.12.2

func (bc BuildContext) WithSubNamespace(namespace string) BuildContext

WithSubNamespace creates a new build context with a more specific namespace

type Builder

type Builder interface {
	ID() string
	Type() string
	Build(BuildContext) ([]Operator, error)
}

Builder is an entity that can build a single operator

type Config

type Config struct {
	Builder
}

Config is the configuration of an operator

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON will marshal a config to JSON.

func (Config) MarshalYAML

func (c Config) MarshalYAML() (interface{}, error)

MarshalYAML will marshal a config to YAML.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(bytes []byte) error

UnmarshalJSON will unmarshal a config from JSON.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML will unmarshal a config from YAML.

type Operator

type Operator interface {
	// ID returns the id of the operator.
	ID() string
	// Type returns the type of the operator.
	Type() string

	// Start will start the operator.
	Start() error
	// Stop will stop the operator.
	Stop() error

	// CanOutput indicates if the operator will output entries to other operators.
	CanOutput() bool
	// Outputs returns the list of connected outputs.
	Outputs() []Operator
	// SetOutputs will set the connected outputs.
	SetOutputs([]Operator) error

	// CanProcess indicates if the operator will process entries from other operators.
	CanProcess() bool
	// Process will process an entry from an operator.
	Process(context.Context, *entry.Entry) error
	// Logger returns the operator's logger
	Logger() *zap.SugaredLogger
}

Operator is a log monitoring component.

type Registry added in v0.12.2

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a registry for operators and plugins that is used for building types from IDs

func NewRegistry added in v0.12.2

func NewRegistry() *Registry

NewRegistry creates a new registry

func (*Registry) Lookup added in v0.12.2

func (r *Registry) Lookup(configType string) (func() Builder, bool)

Lookup looks up a given config type, prioritizing builtin operators before looking in registered plugins. Its second return value will be false if no builder is registered for that type

func (*Registry) Register added in v0.12.2

func (r *Registry) Register(operatorType string, newBuilder func() Builder)

Register will register a function to an operator type. This function will return a builder for the supplied type.

func (*Registry) RegisterPlugin added in v0.12.2

func (r *Registry) RegisterPlugin(pluginName string, newBuilder func() Builder)

RegisterPlugin will register a function to an plugin type. This function will return a builder for the supplied type.

Jump to

Keyboard shortcuts

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