Documentation
¶
Overview ¶
Package transformation provides transformation model configuration and validation
Index ¶
- Constants
- Variables
- func ApplyIntervalOverride(override *IntervalOverride, existingMin, existingMax uint64) (minVal, maxVal uint64, found bool)
- func ApplyMinMaxOverride(override *LimitsOverride, existingMin, existingMax uint64) (minVal, maxVal uint64, found bool)
- func ApplyScheduleOverride(existingSchedule string, override *string) string
- func ApplySchedulesOverride(existingForwardFill, existingBackfill string, override *SchedulesOverride) (forwardFill, backfill string)
- func ApplyTagsOverride(existingTags, overrideTags []string) []string
- func CopyTags(tags []string) []string
- func DecodeStrict[T any](data []byte) (*T, error)
- func RegisterHandler(transformationType Type, factory HandlerFactory)
- func ValidateScheduleFormat(schedule string) error
- type AdminTable
- type Config
- type Dependency
- type DependencyBase
- func (b *DependencyBase) GetAdminTable() AdminTable
- func (b *DependencyBase) GetDependencies() []Dependency
- func (b *DependencyBase) GetFlattenedDependencies() []string
- func (b *DependencyBase) GetID() string
- func (b *DependencyBase) GetOriginalDependencies() []Dependency
- func (b *DependencyBase) GetTags() []string
- func (b *DependencyBase) SubstituteDependencyPlaceholders(externalDefaultDB, transformationDefaultDB string)
- type DependencyHandler
- type Exec
- type FillHandler
- type Handler
- type HandlerFactory
- type IntervalHandler
- type IntervalOverride
- type Limits
- type LimitsHandler
- type LimitsOverride
- type Override
- type Registry
- type SQL
- type ScheduleHandler
- type SchedulesOverride
- type TaskInfo
- type Type
Constants ¶
const TypeExec = "exec"
TypeExec identifies exec transformation models
const TypeSQL = "sql"
TypeSQL identifies SQL transformation models
Variables ¶
var ( // ErrDatabaseRequired is returned when database is not specified ErrDatabaseRequired = errors.New("database is required") // ErrTableRequired is returned when table is not specified ErrTableRequired = errors.New("table is required") // ErrUnknownType is returned for unknown transformation types ErrUnknownType = errors.New("unknown transformation type") )
var ( // ErrInvalidDependencyType is returned when dependency has invalid YAML type ErrInvalidDependencyType = errors.New("dependency must be a string or array of strings") // ErrInvalidDependencyArrayItem is returned when dependency array contains non-string ErrInvalidDependencyArrayItem = errors.New("expected string in dependency array") // ErrEmptyDependencyGroup is returned when dependency group is empty ErrEmptyDependencyGroup = errors.New("dependency group cannot be empty") )
var ( // ErrInvalidFrontmatter is returned when frontmatter is invalid ErrInvalidFrontmatter = errors.New("invalid frontmatter") // ErrSQLContentRequired is returned when SQL content is not specified ErrSQLContentRequired = errors.New("sql content is required") )
var ( // ErrExecRequired is returned when exec is not specified ErrExecRequired = errors.New("exec is required") )
var ( // ErrHandlerNotRegistered is returned when no handler is registered for a type ErrHandlerNotRegistered = errors.New("no handler registered for type") )
Functions ¶
func ApplyIntervalOverride ¶ added in v0.1.7
func ApplyIntervalOverride(override *IntervalOverride, existingMin, existingMax uint64) (minVal, maxVal uint64, found bool)
ApplyIntervalOverride applies an optional Min/Max uint64 interval override. Returns the updated min and max values, and whether any override was found.
func ApplyMinMaxOverride ¶ added in v0.0.49
func ApplyMinMaxOverride(override *LimitsOverride, existingMin, existingMax uint64) (minVal, maxVal uint64, found bool)
ApplyMinMaxOverride applies an optional Min/Max uint64 override. Returns the updated min and max values, and whether any override was found. Used for Interval and Limits overrides in incremental transformations.
func ApplyScheduleOverride ¶ added in v0.0.49
ApplyScheduleOverride returns the override schedule if present, otherwise the existing schedule. This is shared between transformation handlers that support schedule overrides.
func ApplySchedulesOverride ¶ added in v0.0.49
func ApplySchedulesOverride(existingForwardFill, existingBackfill string, override *SchedulesOverride) (forwardFill, backfill string)
ApplySchedulesOverride applies optional ForwardFill/Backfill schedule overrides. Returns the updated forwardFill and backfill values. Used for incremental transformation schedule overrides.
func ApplyTagsOverride ¶ added in v0.0.49
ApplyTagsOverride appends override tags to the existing tags. This is shared between incremental and scheduled transformation handlers.
func CopyTags ¶ added in v0.1.7
CopyTags returns a shallow copy of the provided tags slice, preserving a nil input as a nil output.
func DecodeStrict ¶ added in v0.1.7
DecodeStrict unmarshals YAML data into a value of type T using strict decoding (KnownFields), so unknown keys are rejected. This is shared by the transformation type handlers to enforce the same parsing semantics.
func RegisterHandler ¶ added in v0.0.25
func RegisterHandler(transformationType Type, factory HandlerFactory)
RegisterHandler registers a handler factory for a transformation type
func ValidateScheduleFormat ¶
ValidateScheduleFormat validates a cron schedule expression.
Types ¶
type AdminTable ¶ added in v0.0.25
AdminTable holds the configuration for admin tables
type Config ¶
type Config struct {
Type Type `yaml:"type"` // Required: "incremental" or "scheduled"
Database string `yaml:"database"` // Optional, can fall back to default
Table string `yaml:"table"` // Required
Env map[string]string `yaml:"env,omitempty"`
}
Config is the minimal configuration used to determine the transformation type Each type has its own complete configuration structure
func (*Config) IsIncrementalType ¶ added in v0.0.25
IsIncrementalType returns true if this is an incremental transformation
func (*Config) IsScheduledType ¶ added in v0.0.25
IsScheduledType returns true if this is a scheduled transformation
func (*Config) SetDefaults ¶ added in v0.0.8
SetDefaults applies default values to the configuration
type Dependency ¶ added in v0.0.10
type Dependency struct {
// IsGroup indicates if this is an OR group (array) or a single dependency (string)
IsGroup bool
// SingleDep holds the dependency ID for single dependencies
SingleDep string
// GroupDeps holds multiple dependency IDs for OR groups
GroupDeps []string
}
Dependency represents a dependency that can be either a string (AND) or an array of strings (OR)
func DeepCopyDependencies ¶ added in v0.0.49
func DeepCopyDependencies(deps []Dependency) []Dependency
DeepCopyDependencies creates a deep copy of a slice of dependencies.
func SubstituteDependencyPlaceholders ¶ added in v0.0.49
func SubstituteDependencyPlaceholders(deps []Dependency, externalDB, transformationDB string) []Dependency
SubstituteDependencyPlaceholders replaces {{external}} and {{transformation}} placeholders in all dependencies. It returns the original dependencies (deep copy) and modifies the input slice in place.
func (*Dependency) GetAllDependencies ¶ added in v0.0.10
func (d *Dependency) GetAllDependencies() []string
GetAllDependencies returns all dependency IDs from this dependency (flattened)
func (*Dependency) UnmarshalYAML ¶ added in v0.0.10
func (d *Dependency) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements custom YAML unmarshaling for mixed dependency types
type DependencyBase ¶ added in v0.1.7
type DependencyBase struct {
// contains filtered or unexported fields
}
DependencyBase provides the dependency and identity behavior shared by the transformation type handlers. The concrete handlers embed it and wire it to their own config fields at construction time via accessor functions, since the handler config types differ.
func NewDependencyBase ¶ added in v0.1.7
func NewDependencyBase( adminTable AdminTable, identity func() (database, table string), tags func() []string, dependencies func() []Dependency, original func() []Dependency, setOriginal func([]Dependency), ) DependencyBase
NewDependencyBase wires a DependencyBase to a handler's config accessors.
func (*DependencyBase) GetAdminTable ¶ added in v0.1.7
func (b *DependencyBase) GetAdminTable() AdminTable
GetAdminTable returns the admin table configuration.
func (*DependencyBase) GetDependencies ¶ added in v0.1.7
func (b *DependencyBase) GetDependencies() []Dependency
GetDependencies returns the dependencies (after placeholder substitution).
func (*DependencyBase) GetFlattenedDependencies ¶ added in v0.1.7
func (b *DependencyBase) GetFlattenedDependencies() []string
GetFlattenedDependencies returns all dependencies as a flat string array.
func (*DependencyBase) GetID ¶ added in v0.1.7
func (b *DependencyBase) GetID() string
GetID returns the unique identifier for the transformation model.
func (*DependencyBase) GetOriginalDependencies ¶ added in v0.1.7
func (b *DependencyBase) GetOriginalDependencies() []Dependency
GetOriginalDependencies returns the original dependencies before placeholder substitution.
func (*DependencyBase) GetTags ¶ added in v0.1.7
func (b *DependencyBase) GetTags() []string
GetTags returns the tags for this transformation.
func (*DependencyBase) SubstituteDependencyPlaceholders ¶ added in v0.1.7
func (b *DependencyBase) SubstituteDependencyPlaceholders(externalDefaultDB, transformationDefaultDB string)
SubstituteDependencyPlaceholders replaces {{external}} and {{transformation}} placeholders.
type DependencyHandler ¶ added in v0.0.49
type DependencyHandler interface {
GetFlattenedDependencies() []string
GetDependencies() []Dependency
}
DependencyHandler provides dependency information for transformations.
type Exec ¶
type Exec struct {
Config `yaml:",inline"`
Exec string `yaml:"exec"`
Handler Handler `yaml:"-"` // Type-specific handler
}
Exec represents a transformation exec model with YAML config
func (*Exec) GetHandler ¶ added in v0.0.25
GetHandler returns the type-specific handler
func (*Exec) SetDefaultDatabase ¶ added in v0.0.8
SetDefaultDatabase applies the default database if not already set
type FillHandler ¶ added in v0.0.49
type FillHandler interface {
GetFillDirection() string
AllowGapSkipping() bool
GetFillBuffer() uint64
}
FillHandler provides fill configuration for transformations.
type Handler ¶ added in v0.0.25
type Handler interface {
// Type returns the transformation type
Type() Type
// Config returns the typed configuration
Config() any
// Validate validates the configuration
Validate() error
// ShouldTrackPosition indicates if this type tracks positions
ShouldTrackPosition() bool
// GetTemplateVariables returns template variables for this transformation
GetTemplateVariables(ctx context.Context, taskInfo TaskInfo) map[string]any
// GetAdminTable returns the admin table configuration for this type
GetAdminTable() AdminTable
// RecordCompletion records the completion of a transformation
RecordCompletion(ctx context.Context, adminService any, modelID string, taskInfo TaskInfo) error
}
Handler defines the interface for transformation type handlers
func CreateHandler ¶ added in v0.0.25
func CreateHandler(transformationType Type, data []byte, adminTable AdminTable) (Handler, error)
CreateHandler creates a handler for the given type
type HandlerFactory ¶ added in v0.0.25
type HandlerFactory func(data []byte, adminTable AdminTable) (Handler, error)
HandlerFactory is a function that creates a handler from YAML data
type IntervalHandler ¶ added in v0.0.49
type IntervalHandler interface {
GetMinInterval() uint64
GetMaxInterval() uint64
AllowsPartialIntervals() bool
AllowGapSkipping() bool
}
IntervalHandler provides interval configuration for transformations. Handlers that process data in intervals should implement this interface.
type IntervalOverride ¶ added in v0.1.7
type IntervalOverride struct {
Max *uint64 `yaml:"max,omitempty"`
Min *uint64 `yaml:"min,omitempty"`
}
IntervalOverride allows overriding interval configuration
type LimitsHandler ¶ added in v0.0.49
type LimitsHandler interface {
GetLimits() *Limits
}
LimitsHandler provides position limits for transformations. This is a subset of ScheduleHandler for cases where only limits are needed.
type LimitsOverride ¶ added in v0.1.7
type LimitsOverride struct {
Min *uint64 `yaml:"min,omitempty"`
Max *uint64 `yaml:"max,omitempty"`
}
LimitsOverride allows overriding position limits
type Override ¶ added in v0.1.7
type Override struct {
// Incremental transformation fields
Interval *IntervalOverride `yaml:"interval,omitempty"`
Schedules *SchedulesOverride `yaml:"schedules,omitempty"`
Limits *LimitsOverride `yaml:"limits,omitempty"`
// Scheduled transformation fields
Schedule *string `yaml:"schedule,omitempty"`
// Common fields (both types)
Tags []string `yaml:"tags,omitempty"`
}
Override contains override values for transformation model configurations. All fields are optional - nil means keep existing value. The structure is type-agnostic - fields are applied based on the actual transformation type:
- Incremental transformations: interval, schedules (forwardfill/backfill), limits, tags
- Scheduled transformations: schedule, tags
type Registry ¶ added in v0.0.25
type Registry struct {
// contains filtered or unexported fields
}
Registry manages handler factories for different transformation types
type SQL ¶
type SQL struct {
BaseConfig Config `yaml:",inline"` // Base configuration
Handler Handler // Type-specific handler
Content string `yaml:"-"` // SQL content
}
SQL represents a transformation SQL model with YAML frontmatter
func (*SQL) GetHandler ¶ added in v0.0.25
GetHandler returns the type-specific handler
func (*SQL) SetDefaultDatabase ¶ added in v0.0.8
SetDefaultDatabase applies the default database if not already set
type ScheduleHandler ¶ added in v0.0.49
type ScheduleHandler interface {
IsBackfillEnabled() bool
IsForwardFillEnabled() bool
GetLimits() *Limits
}
ScheduleHandler provides scheduling and limits configuration for transformations. Handlers that have directional processing should implement this interface.
type SchedulesOverride ¶ added in v0.1.7
type SchedulesOverride struct {
ForwardFill *string `yaml:"forwardfill"`
Backfill *string `yaml:"backfill"`
}
SchedulesOverride allows overriding schedule configuration nil = keep existing, empty string = disable, non-empty = new schedule
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package incremental provides the incremental transformation type handler
|
Package incremental provides the incremental transformation type handler |
|
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
|
Package scheduled provides the scheduled transformation type handler
|
Package scheduled provides the scheduled transformation type handler |