transform

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 5 Imported by: 0

README

transform

Contains interfaces and methods for transforming data as it moves from a source to a sink.

Each transform must select from both the data and kill channels to prevent goroutine leaks (learn more about goroutine leaks here).

Information for each transform is available in the GoDoc.

Documentation

Index

Constants

View Source
const TransformInvalidFactoryConfig = errors.Error("TransformInvalidFactoryConfig")

TransformInvalidFactoryConfig is returned when an unsupported Transform is referenced in Factory.

Variables

This section is empty.

Functions

This section is empty.

Types

type Process

type Process struct {
	Processors []config.Config `json:"processors"`
}

Process transforms data by applying processors. Each processor is enabled through conditions. This transform uses process Slicers to iteratively modify slices of bytes.

Below is an example that shows how a single JSON object is iteratively modified through this transform:

{"hello":"world"} // input event
{"hello":"world","foo":"bar"} // insert value "bar" into key "foo"
{"hello":"world","foo":"bar","baz":"qux"} // insert value "qux" into key "bar"
{"hello":"world","foo":"bar.qux"} // concat vaues from "foo" and "baz" into key "foo" with separator "."

The transform uses this Jsonnet configuration:

{
	type: 'process',
	processors: [
		{
			"settings": {
				"condition": {
					"inspectors": [ ],
					"operator": ""
				},
				"input": {
					"key": "@this"
				},
				"options": {
					"algorithm": "sha256"
				},
				"output": {
					"key": "event.hash"
				}
			},
			"type": "hash"
		},
	]
}

func (*Process) Transform

func (transform *Process) Transform(ctx context.Context, in <-chan []byte, out chan<- []byte, kill chan struct{}) error

Transform processes a channel of bytes with the Process transform.

type Transfer

type Transfer struct{}

Transfer transforms data without modification. This transform should be used when data needs to be moved from a source to a sink without data processing.

The transform uses this Jsonnet configuration:

{
	type: 'transfer',
}

func (*Transfer) Transform

func (transform *Transfer) Transform(ctx context.Context, in <-chan []byte, out chan<- []byte, kill chan struct{}) error

Transform processes a channel of bytes with the Transfer transform.

type Transform

type Transform interface {
	Transform(context.Context, <-chan []byte, chan<- []byte, chan struct{}) error
}

Transform is an interface for transforming data as it moves from a source to a sink. Transforms read bytes from and write bytes to channels, may optionally modify bytes, and are interruptable via an anonymous struct channel.

func Factory

func Factory(cfg config.Config) (Transform, error)

Factory loads Transforms from a Config. This is the recommended function for retrieving ready-to-use Transforms.

Jump to

Keyboard shortcuts

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