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 ¶
- type Expression
- func (e *Expression) Bytes(index int, msg Message) []byte
- func (e *Expression) BytesEscaped(index int, msg Message) []byte
- func (e *Expression) BytesEscapedLegacy(index int, msg Message) []byte
- func (e *Expression) BytesLegacy(index int, msg Message) []byte
- func (e *Expression) NumDynamicExpressions() int
- func (e *Expression) String(index int, msg Message) string
- func (e *Expression) StringLegacy(index int, msg Message) string
- type Message
- type QueryResolver
- type Resolver
- type StaticResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expression ¶
type Expression struct { ContainsDeprecated bool // TODO: V4 remove this // 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 ¶
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 ¶
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 ¶
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 ¶
type QueryResolver struct {
// contains filtered or unexported fields
}
QueryResolver executes a query and returns a string representation of the result.
func NewQueryResolver ¶
func NewQueryResolver(fn query.Function) *QueryResolver
NewQueryResolver creates a field query resolver that returns the result of a query function.
func (QueryResolver) ResolveBytes ¶
func (q QueryResolver) ResolveBytes(index int, msg Message, escaped, legacy bool) []byte
ResolveBytes returns a byte slice.
func (QueryResolver) ResolveString ¶
func (q QueryResolver) ResolveString(index int, msg Message, escaped, legacy bool) string
ResolveString returns a string.
type Resolver ¶
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 ¶
type StaticResolver string
StaticResolver is a Resolver implementation that simply returns a static string
func (StaticResolver) ResolveBytes ¶
func (s StaticResolver) ResolveBytes(index int, msg Message, escaped, legacy bool) []byte
ResolveBytes returns a byte slice.
func (StaticResolver) ResolveString ¶
func (s StaticResolver) ResolveString(index int, msg Message, escaped, legacy bool) string
ResolveString returns a string.