field

package
v3.47.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package field implements a bloblang interpolation function templating syntax used in some dynamic fields within Benthos. Only the query (right-hand side) part of the bloblang spec is supported within interpolation functions.

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 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 NewExpression added in v3.25.0

func NewExpression(resolvers ...Resolver) *Expression

NewExpression creates a field expression from a slice of resolvers.

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) NumDynamicExpressions added in v3.47.0

func (e *Expression) NumDynamicExpressions() int

NumDynamicExpressions returns the number of dynamic interpolation functions within the expression.

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 QueryResolver added in v3.25.0

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

QueryResolver executes a query and returns a string representation of the result.

func NewQueryResolver added in v3.25.0

func NewQueryResolver(fn query.Function) *QueryResolver

NewQueryResolver creates a field query resolver that returns the result of a query function.

func (QueryResolver) ResolveBytes added in v3.25.0

func (q QueryResolver) ResolveBytes(index int, msg Message, escaped, legacy bool) []byte

ResolveBytes returns a byte slice.

func (QueryResolver) ResolveString added in v3.25.0

func (q QueryResolver) ResolveString(index int, msg Message, escaped, legacy bool) string

ResolveString returns a string.

type Resolver added in v3.25.0

type Resolver interface {
	ResolveString(index int, msg Message, escaped, legacy bool) string
	ResolveBytes(index int, msg Message, escaped, legacy bool) []byte
}

Resolver is an interface for resolving a string containing Bloblang function interpolations into either a string or bytes.

type StaticResolver added in v3.25.0

type StaticResolver string

StaticResolver is a Resolver implementation that simply returns a static string

func (StaticResolver) ResolveBytes added in v3.25.0

func (s StaticResolver) ResolveBytes(index int, msg Message, escaped, legacy bool) []byte

ResolveBytes returns a byte slice.

func (StaticResolver) ResolveString added in v3.25.0

func (s StaticResolver) ResolveString(index int, msg Message, escaped, legacy bool) string

ResolveString returns a string.

Jump to

Keyboard shortcuts

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