mapping

package
v3.21.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mapping provides a parser for the full bloblang mapping spec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assignment

type Assignment interface {
	Apply(value interface{}, ctx AssignmentContext) error
}

Assignment represents a way of assigning a queried value to something within an assignment context. This could be a Benthos message, a variable, a metadata field, etc.

type AssignmentContext

type AssignmentContext struct {
	Maps  map[string]query.Function
	Vars  map[string]interface{}
	Meta  types.Metadata
	Value *interface{}
}

AssignmentContext contains references to all potential assignment destinations of a given mapping.

type Executor

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

Executor is a parsed bloblang mapping that can be executed on a Benthos message.

func NewExecutor

func NewExecutor(mapping string) (*Executor, error)

NewExecutor parses a bloblang mapping and returns an executor to run it, or an error if the parsing fails.

func (*Executor) Exec

func (e *Executor) Exec(ctx query.FunctionContext) (interface{}, error)

Exec this function with a context struct.

func (*Executor) MapPart

func (e *Executor) MapPart(index int, msg Message) (types.Part, error)

MapPart executes the bloblang mapping on a particular message index of a batch. The message is parsed as a JSON document in order to provide the mapping context. Returns an error if any stage of the mapping fails to execute.

A resulting mapped message part is returned, unless the mapping results in a query.Delete value, in which case nil is returned and the part should be discarded.

func (*Executor) ToBytes

func (e *Executor) ToBytes(ctx query.FunctionContext) []byte

ToBytes executes this function for a message of a batch and returns the result marshalled into a byte slice.

func (*Executor) ToString

func (e *Executor) ToString(ctx query.FunctionContext) string

ToString executes this function for a message of a batch and returns the result marshalled into a string.

type Message

type Message interface {
	Get(p int) types.Part
	Len() int
}

Message is an interface type to be given to a query function, 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