Documentation ¶
Overview ¶
Package field implements a bloblang interpolation function templating syntax used in some dynamic fields within Bento. 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 Bento 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, error)
Bytes returns a byte slice representing the expression resolved for a message of a batch.
func (*Expression) NumDynamicExpressions ¶
func (e *Expression) NumDynamicExpressions() int
NumDynamicExpressions returns the number of dynamic interpolation functions within the expression.
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 ¶
ResolveBytes returns a byte slice.
func (QueryResolver) ResolveString ¶
ResolveString returns a string.
type Resolver ¶
type Resolver interface { ResolveString(index int, msg Message, escaped bool) (string, error) ResolveBytes(index int, msg Message, escaped bool) ([]byte, error) }
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 ¶
ResolveBytes returns a byte slice.
func (StaticResolver) ResolveString ¶
ResolveString returns a string.