processor

package
v0.0.0-...-6436ad8 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProcessorConstructor

func RegisterProcessorConstructor(procType string, constructor ProcessorConstructor)

RegisterProcessorConstructor registers a processor constructor of a given type

Types

type Processor

type Processor interface {
	// Config returns the configuration of the processor
	// The returned value must not be modified
	Config() *config.ProcessorConfig

	// Setup is called once when the processor is started
	// It is typically used to establish connections to external systems
	// or to open necessary files
	Setup() error

	// Close is called once when the processor is stopped
	// It is typically used to close established connections
	// or to close opened files
	Close() error

	// OnReceive is called when a metric is received from an input conveyor
	// It returns a slice of metrics that should be sent to output conveyors
	OnReceive(mt metric.Metric) (out []metric.Metric, err error)

	// OnCronTrigger is called when a cron trigger is fired
	// It returns a slice of metrics that should be sent to output conveyors
	OnCronTrigger() (out []metric.Metric, err error)
}

Processor contains all methods that must be implemented by concrete processors

func NewProcessor

func NewProcessor(procType string, cfg *config.ProcessorConfig) (Processor, error)

NewProcessor creates a new processor

type ProcessorConstructor

type ProcessorConstructor func(cfg *config.ProcessorConfig) (Processor, error)

ProcessorConstructor is a function that creates a new processor

type ProcessorRunner

type ProcessorRunner interface {
	// Name returns the name of the processor
	Name() string

	// AddInput adds an input conveyor to the processor
	// The processor will be stopped and started again after this method is called
	AddInput(input *conveyor.Conveyor) error

	// RemoveInput removes an input conveyor from the processor
	// The processor will be stopped and started again after this method is called
	RemoveInput(name string) error

	// AddOutput adds an output conveyor to the processor
	// The processor will be stopped and started again after this method is called
	AddOutput(output *conveyor.Conveyor) error

	// RemoveOutput removes an output conveyor from the processor
	// The processor will be stopped and started again after this method is called
	RemoveOutput(name string) error

	// Start starts the processor
	Start() error

	// IsStarted returns true if the processor is started
	IsStarted() bool

	// Stop stops the processor
	Stop() error
}

ProcessorRunner takes care of running processors

func NewProcessorRunner

func NewProcessorRunner(procType string, cfg *config.ProcessorConfig) (ProcessorRunner, error)

NewProcessorRunner creates a new processor runner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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