mapper

package
Version: v1.20.4 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package mapper implements ways of splicing and mapping batches of messages so that their derivative parts can be processed individually and merged back into the original batch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptSetConditions

func OptSetConditions(conditions []types.Condition) func(*Type)

OptSetConditions sets the conditions used by this type.

func OptSetLogger

func OptSetLogger(l log.Modular) func(*Type)

OptSetLogger sets the logger used by this type.

func OptSetOptReqMap

func OptSetOptReqMap(m map[string]string) func(*Type)

OptSetOptReqMap sets the optional request map used by this type.

func OptSetOptResMap

func OptSetOptResMap(m map[string]string) func(*Type)

OptSetOptResMap sets the optional response map used by this type.

func OptSetReqMap

func OptSetReqMap(m map[string]string) func(*Type)

OptSetReqMap sets the mandatory request map used by this type.

func OptSetResMap

func OptSetResMap(m map[string]string) func(*Type)

OptSetResMap sets the mandatory response map used by this type.

func OptSetStats

func OptSetStats(s metrics.Type) func(*Type)

OptSetStats sets the metrics aggregator used by this type.

Types

type Type

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

Type contains conditions and maps for transforming a batch of messages into a subset of request messages, and mapping results from those requests back into the original message batch.

func New

func New(opts ...func(*Type)) (*Type, error)

New creates a new mapper Type.

func (*Type) AlignResult added in v0.23.3

func (t *Type) AlignResult(length int, skipped, failed []int, result []types.Message) (types.Message, error)

AlignResult takes the original length of a mapped payload, a slice of skipped message part indexes, a slice of failed message part indexes, and a post-mapped, post-processed slice of resulting messages, and attempts to create a new payload where the results are realigned and ready to map back into the original.

func (*Type) MapRequests

func (t *Type) MapRequests(msg types.Message) (skipped, failed []int)

MapRequests takes a single payload (of potentially multiple parts, where parts can potentially be nil) and maps the parts.

Two arrays are also returned, the first containing all message part indexes that were skipped due to either failed conditions or for being empty. The second contains only message part indexes that failed their map stage.

func (*Type) MapResponses

func (t *Type) MapResponses(payload, response types.Message) ([]int, error)

MapResponses attempts to merge a batch of responses with original payloads as per the response map.

The count of parts within the response message must match the original payload. If parts were removed from the enrichment request the original contents must be interlaced back within the response object before calling the overlay.

Returns an array of message indexes that failed their map stage, or an error.

func (*Type) TargetsProvided

func (t *Type) TargetsProvided() []string

TargetsProvided returns a list of dot paths that this mapper provides.

func (*Type) TargetsUsed

func (t *Type) TargetsUsed() []string

TargetsUsed returns a list of dot paths that this mapper depends on.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL