bloblang

package
v3.62.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package bloblang is DEPRECATED. Please use ./public/bloblang instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field interface {
	// Bytes returns a byte slice representing the expression resolved for a
	// message of a batch.
	Bytes(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
}

Field 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 NewField

func NewField(expr string) (Field, error)

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

When a parsing error occurs the returned error will be a *parser.Error type, which allows you to gain positional and structured error messages.

type Mapping

type Mapping interface {
	// QueryPart executes a Bloblang mapping and expects a boolean result, which
	// is returned. If the execution fails or the result is not boolean an error
	// is returned.
	//
	// Bloblang is able to query other messages of a batch, and therefore this
	// function takes a message batch and index rather than a single message
	// part argument.
	QueryPart(index int, msg Message) (bool, error)

	// MapPart executes a Bloblang mapping on a message part and returns a new
	// resulting part, or an error if the execution fails.
	//
	// Bloblang is able to query other messages of a batch, and therefore this
	// function takes a message batch and index rather than a single message
	// part argument.
	MapPart(index int, msg Message) (types.Part, error)
}

Mapping is a parsed Bloblang mapping.

func NewMapping

func NewMapping(expr string) (Mapping, error)

NewMapping attempts to parse and create a Bloblang mapping from a string. If the mapping was read from a file the path should be provided in order to resolve relative imports, otherwise the path can be left empty.

When a parsing error occurs the returned error may be a *parser.Error type, which allows you to gain positional and structured error messages.

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.

Jump to

Keyboard shortcuts

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