expression

package
v3.12.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package expression implements a Benthos dynamic field expression and the parser combinators for parsing them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

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

Expression represents a dynamic Benthos field expression.

func Parse

func Parse(expr string) (*Expression, error)

Parse a string into a Benthos dynamic field expression.

func (*Expression) Bytes

func (e *Expression) Bytes(index int, msg Message) []byte

Bytes returns a byte slice representing the expression resolved for a message of a batch.

func (*Expression) BytesEscaped

func (e *Expression) BytesEscaped(index int, msg Message) []byte

BytesEscaped returns a byte slice representing the expression resolved for a message of a batch with the contents of resolved expressions escaped.

func (*Expression) BytesEscapedLegacy

func (e *Expression) BytesEscapedLegacy(index int, msg Message) []byte

BytesEscapedLegacy is DEPRECATED - Instructs deprecated functions to disregard index information. TODO V4: Remove this.

func (*Expression) BytesLegacy

func (e *Expression) BytesLegacy(index int, msg Message) []byte

BytesLegacy is DEPRECATED - Instructs deprecated functions to disregard index information. TODO V4: Remove this.

func (*Expression) String

func (e *Expression) String(index int, msg Message) string

String returns a string representing the expression resolved for a message of a batch.

func (*Expression) StringLegacy

func (e *Expression) StringLegacy(index int, msg Message) string

StringLegacy is DEPRECATED - Instructs deprecated functions to disregard index information. TODO V4: Remove this.

type Message

type Message interface {
	Get(p int) types.Part
	Len() int
}

Message is an interface type to be given to a function interpolator, it allows the function to resolve fields and metadata from a message.

type Type

type Type interface {
	// Bytes returns a byte slice representing the expression resolved for a
	// message
	// of a batch.
	Bytes(index int, msg Message) []byte

	// BytesLegacy is DEPRECATED - Instructs deprecated functions to disregard
	// index information.
	// TODO V4: Remove this.
	BytesLegacy(index int, msg Message) []byte

	// BytesEscaped returns a byte slice representing the expression resolved
	// for a message of a batch with the contents of resolved expressions
	// escaped.
	BytesEscaped(index int, msg Message) []byte

	// BytesEscapedLegacy is DEPRECATED - Instructs deprecated functions to
	// disregard index information.
	// TODO V4: Remove this.
	BytesEscapedLegacy(index int, msg Message) []byte

	// String returns a string representing the expression resolved for a
	// message of a batch.
	String(index int, msg Message) string

	// StringLegacy is DEPRECATED - Instructs deprecated functions to disregard
	// index information.
	// TODO V4: Remove this.
	StringLegacy(index int, msg Message) string
}

Type represents a Benthos dynamic field expression, used to configure string fields where the contents should change based on the contents of messages and other factors.

Each function here resolves the expression for a particular message of a batch, this is why an index is expected.

func New

func New(expr string) (Type, error)

New attempts to parse and create an expression from a string. If the expression is invalid an error is returned.

Jump to

Keyboard shortcuts

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