operator

package
v0.13.13-0...-98661b4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

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

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

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

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

func (bc BuildContext) Copy() BuildContext

Copy creates a copy of the build context

func (BuildContext) PrependNamespace

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

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

func (bc BuildContext) WithIncrementedDepth() BuildContext

WithIncrementedDepth returns a new build context with an incremented plugin depth

func (BuildContext) WithSubNamespace

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

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

func NewRegistry() *Registry

NewRegistry creates a new registry

func (*Registry) Lookup

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

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

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