mapping

package
v3.15.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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