operator

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 14 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefined

func IsDefined(operatorType string) bool

IsDefined will return a boolean indicating if an operator type is registered and defined.

func Register

func 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.

Types

type BuildContext

type BuildContext struct {
	PluginRegistry PluginRegistry
	Database       Database
	Parameters     map[string]interface{}
	Logger         *zap.SugaredLogger
}

BuildContext supplies contextual resources when building an operator.

type Builder

type Builder interface {
	ID() string
	Type() string
	Build(BuildContext) (Operator, error)
	SetNamespace(namespace string, exclude ...string)
}

Builder is an entity that can build operators

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 Database

type Database interface {
	Close() error
	Sync() error
	Update(func(*bbolt.Tx) error) error
	View(func(*bbolt.Tx) error) error
}

Database is a database used to save offsets

type Duration

type Duration struct {
	time.Duration
}

Duration is the representation of a length of time

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON will marshal the duration as a json string

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML will marshal the duration as a yaml string

func (*Duration) Raw

func (d *Duration) Raw() time.Duration

Raw will return the raw duration, without modification

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(raw []byte) error

UnmarshalJSON will unmarshal json as a duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML will unmarshal yaml as a duration

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 PluginConfig

type PluginConfig struct {
	Version     string
	Title       string
	Description string
	Parameters  map[string]PluginParameter
	Pipeline    []Config
}

PluginConfig is the rendered config of a plugin.

type PluginParameter

type PluginParameter struct {
	Label       string
	Description string
	Required    bool
	Type        string      // "string", "int", "bool", "strings", or "enum"
	ValidValues []string    `yaml:"valid_values"` // only useable if Type == "enum"
	Default     interface{} // Must be valid according to Type & ValidValues
}

PluginParameter is a basic description of a plugin's parameter.

type PluginRegistry

type PluginRegistry map[string]*template.Template

PluginRegistry is a registry of plugin templates.

func NewPluginRegistry

func NewPluginRegistry(dir string) (PluginRegistry, error)

NewPluginRegistry creates a new plugin registry from a plugin directory.

func (PluginRegistry) Add

func (r PluginRegistry) Add(pluginType string, contents string) error

Add will add a plugin to the registry.

func (PluginRegistry) IsDefined

func (r PluginRegistry) IsDefined(pluginType string) bool

IsDefined returns a boolean indicating if a plugin is defined and registered.

func (PluginRegistry) Load

func (r PluginRegistry) Load(path string) error

Load will load a plugin template from a file path.

func (PluginRegistry) LoadAll

func (r PluginRegistry) LoadAll(dir string, pattern string) error

LoadAll will load all plugin templates contained in a directory.

func (PluginRegistry) Render

func (r PluginRegistry) Render(pluginType string, params map[string]interface{}) (PluginConfig, error)

Render will render a plugin config using the params and plugin type.

type StubDatabase

type StubDatabase struct{}

StubDatabase is an implementation of Database that succeeds on all calls without persisting anything to disk. This is used when --database is unspecified.

func NewStubDatabase

func NewStubDatabase() *StubDatabase

NewStubDatabase creates a new StubDatabase

func (*StubDatabase) Close

func (d *StubDatabase) Close() error

Close will be ignored by the stub database

func (*StubDatabase) Sync

func (d *StubDatabase) Sync() error

Sync will be ignored by the stub database

func (*StubDatabase) Update

func (d *StubDatabase) Update(func(tx *bbolt.Tx) error) error

Update will be ignored by the stub database

func (*StubDatabase) View

func (d *StubDatabase) View(func(tx *bbolt.Tx) error) error

View will be ignored by the stub database

Jump to

Keyboard shortcuts

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