Documentation
¶
Index ¶
- func CheckAndRecord(cfg *MappingConfig) (correlationID string, done func(success bool), err error)
- func Execute(ctx context.Context, cfg *MappingConfig, pkt *packet.DataPacket, dryRun bool) error
- func ExecuteWithOptions(ctx context.Context, cfg *MappingConfig, pkt *packet.DataPacket, ...) error
- type ConnConfig
- type ExecOptions
- type FieldMapping
- type InputSource
- type LoopGuard
- type MappingConfig
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAndRecord ¶
func CheckAndRecord(cfg *MappingConfig) (correlationID string, done func(success bool), err error)
CheckAndRecord verifies loop guard rules (Layers 2+4) and records the new run. Returns a correlation ID and a cleanup function that marks the run as completed. Returns an error if the run should be blocked.
func Execute ¶
func Execute(ctx context.Context, cfg *MappingConfig, pkt *packet.DataPacket, dryRun bool) error
Execute applies cfg to pkt: remaps fields for each target and upserts into the target DB. When dryRun is true the transformation is performed but no data is written.
func ExecuteWithOptions ¶
func ExecuteWithOptions(ctx context.Context, cfg *MappingConfig, pkt *packet.DataPacket, opts ExecOptions) error
ExecuteWithOptions is Execute with room for settings that are not "dry run".
Types ¶
type ConnConfig ¶
type ConnConfig struct {
Type string `yaml:"type"` // "postgres", "mssql", "sqlite"
DSN string `yaml:"dsn"`
Schema string `yaml:"schema,omitempty"` // default schema; overridden by dotted table names
}
ConnConfig describes a target database connection.
type ExecOptions ¶
type ExecOptions struct {
// DryRun performs the transformation without writing anything.
DryRun bool
// Quiet drops the per-target progress line. The caller reports the result
// instead — a drain that consumes forty messages should not print forty
// lines when the scheduler only wants the total.
Quiet bool
// Output receives the dry-run plan and progress. Nil keeps stdout for v1.
Output io.Writer
}
ExecOptions controls a mapping run.
type FieldMapping ¶
type FieldMapping struct {
From string `yaml:"from"`
To string `yaml:"to"`
Enum map[string]string `yaml:"enum,omitempty"` // value remap: source value → target value
}
FieldMapping describes a single field transformation.
type InputSource ¶
type InputSource struct {
Type string `yaml:"type"` // "s3" | "broker"
S3 *storage.S3Config `yaml:"s3,omitempty"`
Broker *brokers.Config `yaml:"broker,omitempty"`
}
InputSource describes where the input TDTP packet comes from. When absent from the mapping YAML, --input must be a local file path.
type LoopGuard ¶
type LoopGuard struct {
SourceSystem string `yaml:"source_system"`
TargetSystem string `yaml:"target_system"`
MinInterval string `yaml:"min_interval"` // e.g. "10s", "1m"
}
LoopGuard prevents recursive sync loops between systems.
type MappingConfig ¶
type MappingConfig struct {
ID string `yaml:"id"`
Version string `yaml:"version"`
ApprovedBy string `yaml:"approved_by,omitempty"`
LoopGuard LoopGuard `yaml:"loop_guard"`
InputSource *InputSource `yaml:"input_source,omitempty"`
TargetConn ConnConfig `yaml:"target_connection"`
Targets []Target `yaml:"targets"`
}
MappingConfig is the top-level structure parsed from a mapping YAML file.
func ParseFile ¶
func ParseFile(path string) (*MappingConfig, error)
ParseFile reads and validates a mapping YAML file.