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 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 }
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.
type Message ¶
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.