mapping

package
v0.0.0-...-7fbf898 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package mapping contains methods and mechanisms for executing a mapping config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateArgSource

EvaluateArgSource extracts a specified value from the arguments (or their subfields) or the context. Given a FromSource pb message, the function will check the args (which should be passed down from whatever projector this FromSource is used from), and/or the context, deciding on its own whether the former or latter is appropriate based on the content of FromSource.

func EvaluateFromDestination

EvaluateFromDestination returns the field from the output specified by the given path.

func EvaluateFromVar

EvaluateFromVar returns the context variable with the given name, or an error if it was not found.

func EvaluateValueSource

EvaluateValueSource "interprets" a single value source. The source is converted into a JSONToken representation of its value (or an error). More specifically, the value of each argument is either evaluated or fetched from the corresponding source/environment. Then each set of argument is passed into the projector, the resulting value is stored into a JSONMetaNode.

func ParentInfoFromArgs

func ParentInfoFromArgs(args []jsonutil.JSONMetaNode, segs []string) (jsonutil.JSONMetaNode, []string, error)

ParentInfoFromArgs finds the longest (prefix) subset of the given path segments that are present in the argument ancestors. Returns this ancestor and the remaining path relative to it.

Types

type Engine

type Engine interface {
	ProcessMappings(maps []*mappb.FieldMapping, projName string, args []jsonutil.JSONMetaNode, output *jsonutil.JSONToken, pctx *types.Context) error
	EvaluateValueSource(vs *mappb.ValueSource, args []jsonutil.JSONMetaNode, output jsonutil.JSONToken, pctx *types.Context) (jsonutil.JSONMetaNode, error)
}

Engine defines an interface for mapping processing engine.

func NewWhistler

func NewWhistler() Engine

NewWhistler creates a new Whistler instance as Engine.

type Whistler

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

Whistler is an implementation of Engine which processes mappings sequentially.

func (Whistler) EvaluateMapping

func (w Whistler) EvaluateMapping(m *mappb.FieldMapping, args []jsonutil.JSONMetaNode, output *jsonutil.JSONToken, pctx *types.Context) error

EvaluateMapping evaluates and assigns a single field mapping sequentially. This method will check the condition as well, returning false if the condition check successfully evaluated to false. The JSONToken returned is the resulting value of this mapping (including a top level object if that was the target).

func (Whistler) EvaluateValueSource

func (w Whistler) EvaluateValueSource(vs *mappb.ValueSource, args []jsonutil.JSONMetaNode, output jsonutil.JSONToken, pctx *types.Context) (jsonutil.JSONMetaNode, error)

EvaluateValueSource evaluates a single value source with a DefaultAccessor.

func (Whistler) ProcessMappings

func (w Whistler) ProcessMappings(maps []*mappb.FieldMapping, projName string, args []jsonutil.JSONMetaNode, output *jsonutil.JSONToken, pctx *types.Context) error

ProcessMappings evaluates mappings in a projector or root mappings.

Jump to

Keyboard shortcuts

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