operator

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 26

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 operator type.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

Types

type Builder

type Builder interface {
	ID() string
	Type() string
	Build(*zap.SugaredLogger) (Operator, error)
	SetID(string)
}

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(Persister) 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
	// GetOutputIDs returns the list of connected outputs.
	GetOutputIDs() []string
	// SetOutputs will set the connected outputs.
	SetOutputs([]Operator) error
	// SetOutputIDs will set the connected outputs' IDs.
	SetOutputIDs([]string)

	// 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 Persister added in v0.18.0

type Persister interface {
	Get(context.Context, string) ([]byte, error)
	Set(context.Context, string, []byte) error
	Delete(context.Context, string) error
}

Persister is an interface used to persist data

func NewScopedPersister added in v0.18.0

func NewScopedPersister(s string, p Persister) Persister

type Registry

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

Registry is used to track and retrieve known operator types

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 operator type. 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.

Jump to

Keyboard shortcuts

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