Documentation ¶
Overview ¶
Package mapping contains methods and mechanisms for executing a mapping config.
Index ¶
- func EvaluateArgSource(vs *mappb.ValueSource_InputSource, args []jsonutil.JSONMetaNode, ...) (jsonutil.JSONMetaNode, error)
- func EvaluateFromDestination(vs *mappb.ValueSource_FromDestination, output jsonutil.JSONToken, ...) (jsonutil.JSONToken, error)
- func EvaluateFromVar(vs *mappb.ValueSource_FromLocalVar, pctx *types.Context, ...) (jsonutil.JSONToken, error)
- func EvaluateValueSource(vs *mappb.ValueSource, args []jsonutil.JSONMetaNode, output jsonutil.JSONToken, ...) (jsonutil.JSONMetaNode, error)
- func ParentInfoFromArgs(args []jsonutil.JSONMetaNode, segs []string) (jsonutil.JSONMetaNode, []string, error)
- type Engine
- type Whistler
- func (w Whistler) EvaluateMapping(m *mappb.FieldMapping, args []jsonutil.JSONMetaNode, ...) error
- func (w Whistler) EvaluateValueSource(vs *mappb.ValueSource, args []jsonutil.JSONMetaNode, output jsonutil.JSONToken, ...) (jsonutil.JSONMetaNode, error)
- func (w Whistler) ProcessMappings(maps []*mappb.FieldMapping, projName string, args []jsonutil.JSONMetaNode, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateArgSource ¶
func EvaluateArgSource(vs *mappb.ValueSource_InputSource, args []jsonutil.JSONMetaNode, pctx *types.Context) (jsonutil.JSONMetaNode, error)
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 ¶
func EvaluateFromDestination(vs *mappb.ValueSource_FromDestination, output jsonutil.JSONToken, a jsonutil.JSONTokenAccessor) (jsonutil.JSONToken, error)
EvaluateFromDestination returns the field from the output specified by the given path.
func EvaluateFromVar ¶
func EvaluateFromVar(vs *mappb.ValueSource_FromLocalVar, pctx *types.Context, a jsonutil.JSONTokenAccessor) (jsonutil.JSONToken, error)
EvaluateFromVar returns the context variable with the given name, or an error if it was not found.
func EvaluateValueSource ¶
func EvaluateValueSource(vs *mappb.ValueSource, args []jsonutil.JSONMetaNode, output jsonutil.JSONToken, pctx *types.Context, a jsonutil.JSONTokenAccessor) (jsonutil.JSONMetaNode, error)
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.
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.