Documentation
¶
Overview ¶
Package mapper compiles a stream's mapper list against its JSON schema and runs the compiled chain on one record at a time.
Index ¶
Constants ¶
const ( OnErrorFail = "fail" OnErrorNull = "null" OnErrorSkip = "skip" )
OnError values.
const ( CastString = "string" CastInteger = "integer" CastNumber = "number" CastBoolean = "boolean" CastTimestamp = "timestamp" CastDatetime = "datetime" CastDate = "date" CastObject = "object" CastArray = "array" )
Cast targets.
const ( FormatISO8601 = "iso8601" FormatUnix = "unix" FormatUnixMs = "unix_ms" )
Timestamp formats besides token patterns.
const DefaultCostLimit uint64 = 100000
DefaultCostLimit is the CEL cost limit per expression evaluation when Input.CostLimit is zero.
const SelectionStep = -1
SelectionStep is the Issue.Step of a problem with the field selection.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CastSpec ¶
type CastSpec struct {
To string `json:"to"`
Format string `json:"format,omitempty"`
Timezone string `json:"timezone,omitempty"`
DecimalSeparator string `json:"decimal_separator,omitempty"`
ThousandsSeparator string `json:"thousands_separator,omitempty"`
Trim bool `json:"trim,omitempty"`
StripPrefix string `json:"strip_prefix,omitempty"`
StripSuffix string `json:"strip_suffix,omitempty"`
TrueValues []string `json:"true_values,omitempty"`
FalseValues []string `json:"false_values,omitempty"`
Source string `json:"source,omitempty"`
OnError string `json:"on_error,omitempty"`
}
CastSpec converts one field to a target type.
func (*CastSpec) UnmarshalJSON ¶
UnmarshalJSON accepts either a full spec object or a bare target string.
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is a compiled mapper list, safe for concurrent use.
type Input ¶
type Input struct {
Schema json.RawMessage
Steps []Step
SelectedFields []protocol.SelectedField
PrimaryKey [][]string
CursorField []string
SyncMode protocol.SyncMode
DestinationSyncMode protocol.DestinationSyncMode
Salt []byte
CostLimit uint64
}
Input is everything Compile needs about one stream.
type Issue ¶
type Issue struct {
Step int `json:"step"`
Field string `json:"field,omitempty"`
Message string `json:"message"`
}
Issue is a problem found in one step, or in the field selection when Step is SelectionStep.
type MaskSpec ¶
type MaskSpec struct {
KeepFirst int `json:"keep_first,omitempty"`
KeepLast int `json:"keep_last,omitempty"`
}
MaskSpec keeps the first and last characters of a value and stars the rest.
type Result ¶
type Result struct {
Schema json.RawMessage
PrimaryKey [][]string
CursorField []string
Errors []Issue
Warnings []Issue
}
Result is the output of Compile: the output schema, primary key and cursor field, or the issues found. CursorField is nil when a step dropped the cursor.
type Step ¶
type Step struct {
Rename map[string]string `json:"rename,omitempty"`
Cast map[string]CastSpec `json:"cast,omitempty"`
Set map[string]string `json:"set,omitempty"`
Hash []string `json:"hash,omitempty"`
Mask map[string]MaskSpec `json:"mask,omitempty"`
Filter *string `json:"filter,omitempty"`
Drop []string `json:"drop,omitempty"`
OnError string `json:"on_error,omitempty"`
}
Step is one mapper of a stream's chain. Exactly one mapper field is set.