entity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package entity defines the core domain entities for the Morpheus library. It contains the Transformer interface and 50+ built-in transformer implementations, the TransformerRegistry, Pipeline, Stage, Job entities, and TransformContext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddDurationTransformer

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

AddDurationTransformer adds a duration to a time

func NewAddDurationTransformer

func NewAddDurationTransformer(durationStr string) *AddDurationTransformer

NewAddDurationTransformer creates a new add duration transformer

func (*AddDurationTransformer) Category

func (t *AddDurationTransformer) Category() string

Category returns the transformer category

func (*AddDurationTransformer) Description

func (t *AddDurationTransformer) Description() string

Description returns transformer description

func (*AddDurationTransformer) Name

func (t *AddDurationTransformer) Name() string

Name returns the transformer name

func (*AddDurationTransformer) Transform

func (t *AddDurationTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the duration addition

func (*AddDurationTransformer) Validate

func (t *AddDurationTransformer) Validate(input any) error

Validate checks if input is valid

func (*AddDurationTransformer) Version

func (t *AddDurationTransformer) Version() string

Version returns the transformer version

type AddTransformer

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

AddTransformer adds a value to the input

func NewAddTransformer

func NewAddTransformer(value any) *AddTransformer

NewAddTransformer creates a new add transformer

func (*AddTransformer) Category

func (t *AddTransformer) Category() string

Category returns the transformer category

func (*AddTransformer) Description

func (t *AddTransformer) Description() string

Description returns transformer description

func (*AddTransformer) Name

func (t *AddTransformer) Name() string

Name returns the transformer name

func (*AddTransformer) Transform

func (t *AddTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the addition

func (*AddTransformer) Validate

func (t *AddTransformer) Validate(input any) error

Validate checks if input is valid

func (*AddTransformer) Version

func (t *AddTransformer) Version() string

Version returns the transformer version

type AggregateOp

type AggregateOp string

AggregateOp defines the aggregation operation to perform.

const (
	AggSum    AggregateOp = "sum"
	AggAvg    AggregateOp = "avg"
	AggMin    AggregateOp = "min"
	AggMax    AggregateOp = "max"
	AggCount  AggregateOp = "count"
	AggMedian AggregateOp = "median"
)

type AggregationTransformer

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

AggregationTransformer performs a numeric aggregation on a slice of values. Input must be []any where each element is numeric (int, float64, etc).

func NewAggregationTransformer

func NewAggregationTransformer(op AggregateOp) *AggregationTransformer

NewAggregationTransformer creates an aggregation transformer for the given operation.

func (*AggregationTransformer) Category

func (t *AggregationTransformer) Category() string

func (*AggregationTransformer) Description

func (t *AggregationTransformer) Description() string

func (*AggregationTransformer) Name

func (t *AggregationTransformer) Name() string

func (*AggregationTransformer) Transform

func (t *AggregationTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*AggregationTransformer) Validate

func (t *AggregationTransformer) Validate(input any) error

func (*AggregationTransformer) Version

func (t *AggregationTransformer) Version() string

type BranchTransformer

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

BranchTransformer applies multiple transformers in parallel (returns array)

func NewBranchTransformer

func NewBranchTransformer(transformers ...Transformer) *BranchTransformer

func (*BranchTransformer) Category

func (t *BranchTransformer) Category() string

Category returns the transformer category

func (*BranchTransformer) Description

func (t *BranchTransformer) Description() string

Description returns transformer description

func (*BranchTransformer) Name

func (t *BranchTransformer) Name() string

Name returns the transformer name

func (*BranchTransformer) Transform

func (t *BranchTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies all transformers and returns results as array

func (*BranchTransformer) Validate

func (t *BranchTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*BranchTransformer) Version

func (t *BranchTransformer) Version() string

Version returns the transformer version

type ChainTransformer

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

ChainTransformer applies transformers sequentially (pipe)

func NewChainTransformer

func NewChainTransformer(transformers ...Transformer) *ChainTransformer

func (*ChainTransformer) Category

func (t *ChainTransformer) Category() string

Category returns the transformer category

func (*ChainTransformer) Description

func (t *ChainTransformer) Description() string

Description returns transformer description

func (*ChainTransformer) Name

func (t *ChainTransformer) Name() string

Name returns the transformer name

func (*ChainTransformer) Transform

func (t *ChainTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies all transformers in sequence

func (*ChainTransformer) Validate

func (t *ChainTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*ChainTransformer) Version

func (t *ChainTransformer) Version() string

Version returns the transformer version

type ConcatTransformer

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

ConcatTransformer joins multiple strings with a separator

func NewConcatTransformer

func NewConcatTransformer(separator string) *ConcatTransformer

NewConcatTransformer creates a new concat transformer

func (*ConcatTransformer) Category

func (t *ConcatTransformer) Category() string

Category returns the transformer category

func (*ConcatTransformer) Description

func (t *ConcatTransformer) Description() string

Description returns transformer description

func (*ConcatTransformer) Name

func (t *ConcatTransformer) Name() string

Name returns the transformer name

func (*ConcatTransformer) Transform

func (t *ConcatTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the concat transformation

func (*ConcatTransformer) Validate

func (t *ConcatTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*ConcatTransformer) Version

func (t *ConcatTransformer) Version() string

Version returns the transformer version

type ConditionFunc

type ConditionFunc func(input any) bool

ConditionFunc defines a condition function

type ConditionalTransformer

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

ConditionalTransformer applies different transformers based on a condition

func NewConditionalTransformer

func NewConditionalTransformer(
	condition ConditionFunc,
	trueTransformer Transformer,
	falseTransformer Transformer,
) *ConditionalTransformer

func (*ConditionalTransformer) Category

func (t *ConditionalTransformer) Category() string

Category returns the transformer category

func (*ConditionalTransformer) Description

func (t *ConditionalTransformer) Description() string

Description returns transformer description

func (*ConditionalTransformer) Name

func (t *ConditionalTransformer) Name() string

Name returns the transformer name

func (*ConditionalTransformer) Transform

func (t *ConditionalTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the appropriate transformer based on condition

func (*ConditionalTransformer) Validate

func (t *ConditionalTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*ConditionalTransformer) Version

func (t *ConditionalTransformer) Version() string

Version returns the transformer version

type ContextPool

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

ContextPool manages a pool of reusable TransformContext instances Uses sync.Pool for efficient memory reuse across concurrent operations Reduces GC pressure by reusing cleared contexts instead of creating new ones

func NewContextPool

func NewContextPool() *ContextPool

NewContextPool creates a new context pool

func (*ContextPool) Get

func (p *ContextPool) Get() *TransformContext

Get retrieves a context from the pool If the pool is empty, creates a new one via the New function

func (*ContextPool) Put

func (p *ContextPool) Put(ctx *TransformContext)

Put returns a context to the pool after clearing it The context will be reused by subsequent Get() calls

type CountCharactersTransformer

type CountCharactersTransformer struct{}

CountCharactersTransformer counts the characters in a string

func NewCountCharactersTransformer

func NewCountCharactersTransformer() *CountCharactersTransformer

func (*CountCharactersTransformer) Category

func (t *CountCharactersTransformer) Category() string

Category returns the transformer category

func (*CountCharactersTransformer) Description

func (t *CountCharactersTransformer) Description() string

Description returns transformer description

func (*CountCharactersTransformer) Name

Name returns the transformer name

func (*CountCharactersTransformer) Transform

func (t *CountCharactersTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*CountCharactersTransformer) Validate

func (t *CountCharactersTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*CountCharactersTransformer) Version

func (t *CountCharactersTransformer) Version() string

Version returns the transformer version

type DaysBetweenTransformer

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

DaysBetweenTransformer calculates days between two times

func NewDaysBetweenTransformer

func NewDaysBetweenTransformer(referenceTime any) *DaysBetweenTransformer

NewDaysBetweenTransformer creates a new days between transformer

func (*DaysBetweenTransformer) Category

func (t *DaysBetweenTransformer) Category() string

Category returns the transformer category

func (*DaysBetweenTransformer) Description

func (t *DaysBetweenTransformer) Description() string

Description returns transformer description

func (*DaysBetweenTransformer) Name

func (t *DaysBetweenTransformer) Name() string

Name returns the transformer name

func (*DaysBetweenTransformer) Transform

func (t *DaysBetweenTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform calculates the difference in days

func (*DaysBetweenTransformer) Validate

func (t *DaysBetweenTransformer) Validate(input any) error

Validate checks if input is valid

func (*DaysBetweenTransformer) Version

func (t *DaysBetweenTransformer) Version() string

Version returns the transformer version

type DivideTransformer

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

DivideTransformer divides input by a value

func NewDivideTransformer

func NewDivideTransformer(value any) *DivideTransformer

NewDivideTransformer creates a new divide transformer

func (*DivideTransformer) Category

func (t *DivideTransformer) Category() string

Category returns the transformer category

func (*DivideTransformer) Description

func (t *DivideTransformer) Description() string

Description returns transformer description

func (*DivideTransformer) Name

func (t *DivideTransformer) Name() string

Name returns the transformer name

func (*DivideTransformer) Transform

func (t *DivideTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the division

func (*DivideTransformer) Validate

func (t *DivideTransformer) Validate(input any) error

Validate checks if input is valid

func (*DivideTransformer) Version

func (t *DivideTransformer) Version() string

Version returns the transformer version

type ErrorHandling

type ErrorHandling string

ErrorHandling defines how to handle stage failures

const (
	ErrorContinue ErrorHandling = "continue" // Continue on failure
	ErrorStop     ErrorHandling = "stop"     // Stop pipeline on failure
	ErrorOptional ErrorHandling = "optional" // Stage is optional, ignore failure
)

type FieldMappingTransformer

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

FieldMappingTransformer renames keys in a map[string]any according to a mapping definition. Keys not in the mapping are kept unchanged unless DropUnmapped is true.

func NewFieldMappingTransformer

func NewFieldMappingTransformer(mapping map[string]string, dropUnmapped bool) *FieldMappingTransformer

NewFieldMappingTransformer creates a field mapping transformer. mapping maps source field names to destination field names. If dropUnmapped is true, fields not present in the mapping are dropped.

func (*FieldMappingTransformer) Category

func (t *FieldMappingTransformer) Category() string

func (*FieldMappingTransformer) Description

func (t *FieldMappingTransformer) Description() string

func (*FieldMappingTransformer) Name

func (t *FieldMappingTransformer) Name() string

func (*FieldMappingTransformer) Transform

func (t *FieldMappingTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*FieldMappingTransformer) Validate

func (t *FieldMappingTransformer) Validate(input any) error

func (*FieldMappingTransformer) Version

func (t *FieldMappingTransformer) Version() string

type FlattenTransformer

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

FlattenTransformer flattens a nested map into a single-level map using dot-separated keys.

Example:

{"user": {"name": "Alice", "address": {"city": "NYC"}}}
→ {"user.name": "Alice", "user.address.city": "NYC"}

func NewFlattenTransformer

func NewFlattenTransformer(separator string) *FlattenTransformer

NewFlattenTransformer creates a flatten transformer with the given separator. If separator is empty, "." is used as default.

func (*FlattenTransformer) Category

func (t *FlattenTransformer) Category() string

func (*FlattenTransformer) Description

func (t *FlattenTransformer) Description() string

func (*FlattenTransformer) Name

func (t *FlattenTransformer) Name() string

func (*FlattenTransformer) Transform

func (t *FlattenTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*FlattenTransformer) Validate

func (t *FlattenTransformer) Validate(input any) error

func (*FlattenTransformer) Version

func (t *FlattenTransformer) Version() string

type FormatTransformer

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

FormatTransformer formats a time to string using layout

func NewFormatTransformer

func NewFormatTransformer(layout string) *FormatTransformer

NewFormatTransformer creates a new format transformer

func (*FormatTransformer) Category

func (t *FormatTransformer) Category() string

Category returns the transformer category

func (*FormatTransformer) Description

func (t *FormatTransformer) Description() string

Description returns transformer description

func (*FormatTransformer) Name

func (t *FormatTransformer) Name() string

Name returns the transformer name

func (*FormatTransformer) Transform

func (t *FormatTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the formatting

func (*FormatTransformer) Validate

func (t *FormatTransformer) Validate(input any) error

Validate checks if input is valid

func (*FormatTransformer) Version

func (t *FormatTransformer) Version() string

Version returns the transformer version

type HashStringTransformer

type HashStringTransformer struct{}

HashStringTransformer hashes strings using SHA256

func NewHashStringTransformer

func NewHashStringTransformer() *HashStringTransformer

func (*HashStringTransformer) Category

func (t *HashStringTransformer) Category() string

Category returns the transformer category

func (*HashStringTransformer) Description

func (t *HashStringTransformer) Description() string

Description returns transformer description

func (*HashStringTransformer) Name

func (t *HashStringTransformer) Name() string

Name returns the transformer name

func (*HashStringTransformer) Transform

func (t *HashStringTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*HashStringTransformer) Validate

func (t *HashStringTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*HashStringTransformer) Version

func (t *HashStringTransformer) Version() string

Version returns the transformer version

type JSONPathTransformer

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

JSONPathTransformer extracts a value from nested data using a simple dot-notation path (e.g., "user.address.city" or "items.0.name").

Array indices are supported as numeric path segments. This is a lightweight alternative to full JSONPath ($..store.book[*].author).

func NewJSONPathTransformer

func NewJSONPathTransformer(path string) *JSONPathTransformer

NewJSONPathTransformer creates a path extractor with the given dot-notation path.

func (*JSONPathTransformer) Category

func (t *JSONPathTransformer) Category() string

func (*JSONPathTransformer) Description

func (t *JSONPathTransformer) Description() string

func (*JSONPathTransformer) Name

func (t *JSONPathTransformer) Name() string

func (*JSONPathTransformer) Transform

func (t *JSONPathTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*JSONPathTransformer) Validate

func (t *JSONPathTransformer) Validate(input any) error

func (*JSONPathTransformer) Version

func (t *JSONPathTransformer) Version() string

type Job

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

Job represents a unit of work in the queue with immutable creation semantics and mutable state management for lifecycle tracking.

Job uses value semantics for its exported getters (all return copies/values) and internal mutation methods that modify its own state. This pattern allows safe concurrent reads after creation while supporting the necessary state transitions for job lifecycle management (Pending → Processing → Success/Failed).

func NewJob

func NewJob(id string, priority Priority, payload any) *Job

NewJob creates a new job with the given ID, priority, and payload. The job starts in StatusPending state with CreatedAt set to current time. All time fields except CreatedAt are zero-valued initially.

Example:

job := NewJob("transform-123", PriorityHigh, data)
job.MarkProcessing()
// ... do work ...
job.MarkComplete(result)

func (*Job) CompletedAt

func (j *Job) CompletedAt() time.Time

CompletedAt returns the time job processing completed (success or failure). Returns zero time if job hasn't completed.

func (*Job) CreatedAt

func (j *Job) CreatedAt() time.Time

CreatedAt returns the time the job was created.

func (*Job) Error

func (j *Job) Error() error

Error returns any error that occurred during processing. Returns nil if job succeeded or hasn't completed yet.

func (*Job) EstimateComplexity

func (j *Job) EstimateComplexity() time.Duration

EstimateComplexity returns a time duration estimate for processing this job based on the payload size using simple heuristics:

  • < 1KB: 5ms
  • 1KB to 1MB: 50ms
  • > 1MB: 500ms

This is used for queue scheduling and not for actual processing.

func (*Job) ID

func (j *Job) ID() string

ID returns the job's unique identifier.

func (*Job) MarkComplete

func (j *Job) MarkComplete(result any)

MarkComplete updates the job status to StatusSuccess and sets CompletedAt to the current time. The result parameter is for future use (metadata).

This method should be called when job processing completes successfully.

func (*Job) MarkFailed

func (j *Job) MarkFailed(err error)

MarkFailed updates the job status to StatusFailed, stores the error, and sets CompletedAt to the current time.

This method should be called when job processing encounters an error. The error parameter can be nil.

func (*Job) MarkProcessing

func (j *Job) MarkProcessing()

MarkProcessing updates the job status to StatusProcessing and sets StartedAt to the current time. Can be called multiple times; each call updates StartedAt.

This method should be called when the job begins execution.

func (*Job) MarshalJSON

func (j *Job) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for Job

func (*Job) Payload

func (j *Job) Payload() any

Payload returns the job's data payload.

func (*Job) Priority

func (j *Job) Priority() Priority

Priority returns the job's priority level.

func (*Job) StartedAt

func (j *Job) StartedAt() time.Time

StartedAt returns the time job processing started. Returns zero time if job hasn't started processing.

func (*Job) Status

func (j *Job) Status() valueobject.Status

Status returns the current job status.

func (*Job) UnmarshalJSON

func (j *Job) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for Job

type LowerCaseTransformer

type LowerCaseTransformer struct{}

LowerCaseTransformer converts strings to lowercase

func NewLowerCaseTransformer

func NewLowerCaseTransformer() *LowerCaseTransformer

NewLowerCaseTransformer creates a new lowercase transformer

func (*LowerCaseTransformer) Category

func (t *LowerCaseTransformer) Category() string

Category returns the transformer category

func (*LowerCaseTransformer) Description

func (t *LowerCaseTransformer) Description() string

Description returns transformer description

func (*LowerCaseTransformer) Name

func (t *LowerCaseTransformer) Name() string

Name returns the transformer name

func (*LowerCaseTransformer) Transform

func (t *LowerCaseTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the lowercase transformation

func (*LowerCaseTransformer) Validate

func (t *LowerCaseTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*LowerCaseTransformer) Version

func (t *LowerCaseTransformer) Version() string

Version returns the transformer version

type MaskEmailTransformer

type MaskEmailTransformer struct{}

MaskEmailTransformer masks email addresses

func NewMaskEmailTransformer

func NewMaskEmailTransformer() *MaskEmailTransformer

func (*MaskEmailTransformer) Category

func (t *MaskEmailTransformer) Category() string

Category returns the transformer category

func (*MaskEmailTransformer) Description

func (t *MaskEmailTransformer) Description() string

Description returns transformer description

func (*MaskEmailTransformer) Name

func (t *MaskEmailTransformer) Name() string

Name returns the transformer name

func (*MaskEmailTransformer) Transform

func (t *MaskEmailTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*MaskEmailTransformer) Validate

func (t *MaskEmailTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*MaskEmailTransformer) Version

func (t *MaskEmailTransformer) Version() string

Version returns the transformer version

type MaskPhoneTransformer

type MaskPhoneTransformer struct{}

MaskPhoneTransformer masks phone numbers

func NewMaskPhoneTransformer

func NewMaskPhoneTransformer() *MaskPhoneTransformer

func (*MaskPhoneTransformer) Category

func (t *MaskPhoneTransformer) Category() string

Category returns the transformer category

func (*MaskPhoneTransformer) Description

func (t *MaskPhoneTransformer) Description() string

Description returns transformer description

func (*MaskPhoneTransformer) Name

func (t *MaskPhoneTransformer) Name() string

Name returns the transformer name

func (*MaskPhoneTransformer) Transform

func (t *MaskPhoneTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*MaskPhoneTransformer) Validate

func (t *MaskPhoneTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*MaskPhoneTransformer) Version

func (t *MaskPhoneTransformer) Version() string

Version returns the transformer version

type MultiPathTransformer

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

MultiPathTransformer extracts multiple paths from the input and returns a map with the results.

func NewMultiPathTransformer

func NewMultiPathTransformer(paths map[string]string) *MultiPathTransformer

NewMultiPathTransformer creates a transformer that extracts multiple paths. The keys in paths are the output field names, values are dot-notation paths.

func (*MultiPathTransformer) Category

func (t *MultiPathTransformer) Category() string

func (*MultiPathTransformer) Description

func (t *MultiPathTransformer) Description() string

func (*MultiPathTransformer) Name

func (t *MultiPathTransformer) Name() string

func (*MultiPathTransformer) Transform

func (t *MultiPathTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*MultiPathTransformer) Validate

func (t *MultiPathTransformer) Validate(input any) error

func (*MultiPathTransformer) Version

func (t *MultiPathTransformer) Version() string

type MultiplyTransformer

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

MultiplyTransformer multiplies input by a value

func NewMultiplyTransformer

func NewMultiplyTransformer(value any) *MultiplyTransformer

NewMultiplyTransformer creates a new multiply transformer

func (*MultiplyTransformer) Category

func (t *MultiplyTransformer) Category() string

Category returns the transformer category

func (*MultiplyTransformer) Description

func (t *MultiplyTransformer) Description() string

Description returns transformer description

func (*MultiplyTransformer) Name

func (t *MultiplyTransformer) Name() string

Name returns the transformer name

func (*MultiplyTransformer) Transform

func (t *MultiplyTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the multiplication

func (*MultiplyTransformer) Validate

func (t *MultiplyTransformer) Validate(input any) error

Validate checks if input is valid

func (*MultiplyTransformer) Version

func (t *MultiplyTransformer) Version() string

Version returns the transformer version

type NormalizeAddressTransformer

type NormalizeAddressTransformer struct{}

NormalizeAddressTransformer normalizes addresses

func NewNormalizeAddressTransformer

func NewNormalizeAddressTransformer() *NormalizeAddressTransformer

func (*NormalizeAddressTransformer) Category

func (t *NormalizeAddressTransformer) Category() string

Category returns the transformer category

func (*NormalizeAddressTransformer) Description

func (t *NormalizeAddressTransformer) Description() string

Description returns transformer description

func (*NormalizeAddressTransformer) Name

Name returns the transformer name

func (*NormalizeAddressTransformer) Transform

func (t *NormalizeAddressTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*NormalizeAddressTransformer) Validate

func (t *NormalizeAddressTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*NormalizeAddressTransformer) Version

func (t *NormalizeAddressTransformer) Version() string

Version returns the transformer version

type NormalizeEmailTransformer

type NormalizeEmailTransformer struct{}

NormalizeEmailTransformer normalizes email addresses

func NewNormalizeEmailTransformer

func NewNormalizeEmailTransformer() *NormalizeEmailTransformer

func (*NormalizeEmailTransformer) Category

func (t *NormalizeEmailTransformer) Category() string

Category returns the transformer category

func (*NormalizeEmailTransformer) Description

func (t *NormalizeEmailTransformer) Description() string

Description returns transformer description

func (*NormalizeEmailTransformer) Name

Name returns the transformer name

func (*NormalizeEmailTransformer) Transform

func (t *NormalizeEmailTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*NormalizeEmailTransformer) Validate

func (t *NormalizeEmailTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*NormalizeEmailTransformer) Version

func (t *NormalizeEmailTransformer) Version() string

Version returns the transformer version

type NormalizeNameTransformer

type NormalizeNameTransformer struct{}

NormalizeNameTransformer normalizes names by capitalizing words

func NewNormalizeNameTransformer

func NewNormalizeNameTransformer() *NormalizeNameTransformer

func (*NormalizeNameTransformer) Category

func (t *NormalizeNameTransformer) Category() string

Category returns the transformer category

func (*NormalizeNameTransformer) Description

func (t *NormalizeNameTransformer) Description() string

Description returns transformer description

func (*NormalizeNameTransformer) Name

func (t *NormalizeNameTransformer) Name() string

Name returns the transformer name

func (*NormalizeNameTransformer) Transform

func (t *NormalizeNameTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*NormalizeNameTransformer) Validate

func (t *NormalizeNameTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*NormalizeNameTransformer) Version

func (t *NormalizeNameTransformer) Version() string

Version returns the transformer version

type NormalizePhoneTransformer

type NormalizePhoneTransformer struct{}

NormalizePhoneTransformer normalizes phone numbers by removing formatting

func NewNormalizePhoneTransformer

func NewNormalizePhoneTransformer() *NormalizePhoneTransformer

func (*NormalizePhoneTransformer) Category

func (t *NormalizePhoneTransformer) Category() string

Category returns the transformer category

func (*NormalizePhoneTransformer) Description

func (t *NormalizePhoneTransformer) Description() string

Description returns transformer description

func (*NormalizePhoneTransformer) Name

Name returns the transformer name

func (*NormalizePhoneTransformer) Transform

func (t *NormalizePhoneTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*NormalizePhoneTransformer) Validate

func (t *NormalizePhoneTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*NormalizePhoneTransformer) Version

func (t *NormalizePhoneTransformer) Version() string

Version returns the transformer version

type OmitFieldsTransformer

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

OmitFieldsTransformer removes specified fields from a map.

func NewOmitFieldsTransformer

func NewOmitFieldsTransformer(fields []string) *OmitFieldsTransformer

NewOmitFieldsTransformer creates a transformer that removes the listed fields.

func (*OmitFieldsTransformer) Category

func (t *OmitFieldsTransformer) Category() string

func (*OmitFieldsTransformer) Description

func (t *OmitFieldsTransformer) Description() string

func (*OmitFieldsTransformer) Name

func (t *OmitFieldsTransformer) Name() string

func (*OmitFieldsTransformer) Transform

func (t *OmitFieldsTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*OmitFieldsTransformer) Validate

func (t *OmitFieldsTransformer) Validate(input any) error

func (*OmitFieldsTransformer) Version

func (t *OmitFieldsTransformer) Version() string

type ParseTransformer

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

ParseTransformer parses a string into time using layout

func NewParseTransformer

func NewParseTransformer(layout string) *ParseTransformer

NewParseTransformer creates a new parse transformer

func (*ParseTransformer) Category

func (t *ParseTransformer) Category() string

Category returns the transformer category

func (*ParseTransformer) Description

func (t *ParseTransformer) Description() string

Description returns transformer description

func (*ParseTransformer) Name

func (t *ParseTransformer) Name() string

Name returns the transformer name

func (*ParseTransformer) Transform

func (t *ParseTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the parsing

func (*ParseTransformer) Validate

func (t *ParseTransformer) Validate(input any) error

Validate checks if input is valid

func (*ParseTransformer) Version

func (t *ParseTransformer) Version() string

Version returns the transformer version

type PickFieldsTransformer

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

PickFieldsTransformer extracts only the specified fields from a map.

func NewPickFieldsTransformer

func NewPickFieldsTransformer(fields []string) *PickFieldsTransformer

NewPickFieldsTransformer creates a transformer that keeps only the listed fields.

func (*PickFieldsTransformer) Category

func (t *PickFieldsTransformer) Category() string

func (*PickFieldsTransformer) Description

func (t *PickFieldsTransformer) Description() string

func (*PickFieldsTransformer) Name

func (t *PickFieldsTransformer) Name() string

func (*PickFieldsTransformer) Transform

func (t *PickFieldsTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*PickFieldsTransformer) Validate

func (t *PickFieldsTransformer) Validate(input any) error

func (*PickFieldsTransformer) Version

func (t *PickFieldsTransformer) Version() string

type Pipeline

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

Pipeline represents a complete data transformation pipeline

func NewPipeline

func NewPipeline(id, name string) *Pipeline

NewPipeline creates a new pipeline

func (*Pipeline) AddStage

func (p *Pipeline) AddStage(stage *Stage) *Pipeline

AddStage adds a stage to the pipeline

func (*Pipeline) Description

func (p *Pipeline) Description() string

func (*Pipeline) GetStage

func (p *Pipeline) GetStage(name string) (*Stage, bool)

GetStage retrieves a stage by name

func (*Pipeline) ID

func (p *Pipeline) ID() string

Getter methods

func (*Pipeline) Name

func (p *Pipeline) Name() string

func (*Pipeline) StageOrder

func (p *Pipeline) StageOrder() []string

func (*Pipeline) Stages

func (p *Pipeline) Stages() map[string]*Stage

func (*Pipeline) ValidateDAG

func (p *Pipeline) ValidateDAG() error

ValidateDAG validates the pipeline has no cycles and all dependencies exist

func (*Pipeline) WithDescription

func (p *Pipeline) WithDescription(desc string) *Pipeline

WithDescription sets pipeline description

type PipelineResult

type PipelineResult struct {
	PipelineID   string
	Status       StageStatus // Overall status
	StageResults map[string]*StageResult
	Error        error
	Duration     time.Duration
	StartedAt    time.Time
	EndedAt      time.Time
}

PipelineResult represents the result of executing a complete pipeline

func NewPipelineResult

func NewPipelineResult(pipelineID string) *PipelineResult

NewPipelineResult creates a new pipeline result

func (*PipelineResult) AddStageResult

func (pr *PipelineResult) AddStageResult(result *StageResult)

AddStageResult adds a stage result

func (*PipelineResult) Fail

func (pr *PipelineResult) Fail(err error)

Fail marks pipeline as failed

func (*PipelineResult) FailureCount

func (pr *PipelineResult) FailureCount() int

FailureCount returns number of failed stages

func (*PipelineResult) GetStageResult

func (pr *PipelineResult) GetStageResult(stageName string) (*StageResult, bool)

GetStageResult retrieves a stage result

func (*PipelineResult) IsSuccess

func (pr *PipelineResult) IsSuccess() bool

IsSuccess returns true if pipeline succeeded

func (*PipelineResult) Success

func (pr *PipelineResult) Success()

Success marks pipeline as successful

func (*PipelineResult) SuccessCount

func (pr *PipelineResult) SuccessCount() int

SuccessCount returns number of successful stages

type PipelineTransformer

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

PipelineTransformer is an alias for ChainTransformer with a different name

func NewPipelineTransformer

func NewPipelineTransformer(transformers ...Transformer) *PipelineTransformer

func (*PipelineTransformer) Category

func (t *PipelineTransformer) Category() string

Category returns the transformer category

func (*PipelineTransformer) Description

func (t *PipelineTransformer) Description() string

Description returns transformer description

func (*PipelineTransformer) Name

func (t *PipelineTransformer) Name() string

Name returns the transformer name

func (*PipelineTransformer) Transform

func (t *PipelineTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies all transformers in sequence (same as chain)

func (*PipelineTransformer) Validate

func (t *PipelineTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*PipelineTransformer) Version

func (t *PipelineTransformer) Version() string

Version returns the transformer version

type Priority

type Priority int

Priority represents job priority levels

const (
	PriorityHigh   Priority = iota // 0 - Highest priority, 50% workers
	PriorityMedium                 // 1 - Medium priority, 30% workers
	PriorityLow                    // 2 - Lowest priority, 20% workers
)

func (Priority) IsValid

func (p Priority) IsValid() bool

IsValid checks if priority is a valid value

func (Priority) String

func (p Priority) String() string

String returns the string representation of priority

type RepeatStringTransformer

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

RepeatStringTransformer repeats a string N times

func NewRepeatStringTransformer

func NewRepeatStringTransformer(count int) *RepeatStringTransformer

func (*RepeatStringTransformer) Category

func (t *RepeatStringTransformer) Category() string

Category returns the transformer category

func (*RepeatStringTransformer) Description

func (t *RepeatStringTransformer) Description() string

Description returns transformer description

func (*RepeatStringTransformer) Name

func (t *RepeatStringTransformer) Name() string

Name returns the transformer name

func (*RepeatStringTransformer) Transform

func (t *RepeatStringTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*RepeatStringTransformer) Validate

func (t *RepeatStringTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*RepeatStringTransformer) Version

func (t *RepeatStringTransformer) Version() string

Version returns the transformer version

type ReplaceTransformer

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

ReplaceTransformer replaces occurrences of old substring with new substring

func NewReplaceTransformer

func NewReplaceTransformer(old, new string) *ReplaceTransformer

NewReplaceTransformer creates a new replace transformer

func (*ReplaceTransformer) Category

func (t *ReplaceTransformer) Category() string

Category returns the transformer category

func (*ReplaceTransformer) Description

func (t *ReplaceTransformer) Description() string

Description returns transformer description

func (*ReplaceTransformer) Name

func (t *ReplaceTransformer) Name() string

Name returns the transformer name

func (*ReplaceTransformer) Transform

func (t *ReplaceTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the replace transformation

func (*ReplaceTransformer) Validate

func (t *ReplaceTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*ReplaceTransformer) Version

func (t *ReplaceTransformer) Version() string

Version returns the transformer version

type ReplaceWhitespaceTransformer

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

ReplaceWhitespaceTransformer replaces whitespace with a specified character

func NewReplaceWhitespaceTransformer

func NewReplaceWhitespaceTransformer(replacement string) *ReplaceWhitespaceTransformer

func (*ReplaceWhitespaceTransformer) Category

func (t *ReplaceWhitespaceTransformer) Category() string

Category returns the transformer category

func (*ReplaceWhitespaceTransformer) Description

func (t *ReplaceWhitespaceTransformer) Description() string

Description returns transformer description

func (*ReplaceWhitespaceTransformer) Name

Name returns the transformer name

func (*ReplaceWhitespaceTransformer) Transform

func (t *ReplaceWhitespaceTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*ReplaceWhitespaceTransformer) Validate

func (t *ReplaceWhitespaceTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*ReplaceWhitespaceTransformer) Version

func (t *ReplaceWhitespaceTransformer) Version() string

Version returns the transformer version

type ReverseTransformer

type ReverseTransformer struct{}

ReverseTransformer reverses a string

func NewReverseTransformer

func NewReverseTransformer() *ReverseTransformer

func (*ReverseTransformer) Category

func (t *ReverseTransformer) Category() string

Category returns the transformer category

func (*ReverseTransformer) Description

func (t *ReverseTransformer) Description() string

Description returns transformer description

func (*ReverseTransformer) Name

func (t *ReverseTransformer) Name() string

Name returns the transformer name

func (*ReverseTransformer) Transform

func (t *ReverseTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*ReverseTransformer) Validate

func (t *ReverseTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*ReverseTransformer) Version

func (t *ReverseTransformer) Version() string

Version returns the transformer version

type RoundTransformer

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

RoundTransformer rounds to specified decimal places

func NewRoundTransformer

func NewRoundTransformer(decimals int) *RoundTransformer

NewRoundTransformer creates a new round transformer

func (*RoundTransformer) Category

func (t *RoundTransformer) Category() string

Category returns the transformer category

func (*RoundTransformer) Description

func (t *RoundTransformer) Description() string

Description returns transformer description

func (*RoundTransformer) Name

func (t *RoundTransformer) Name() string

Name returns the transformer name

func (*RoundTransformer) Transform

func (t *RoundTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the rounding

func (*RoundTransformer) Validate

func (t *RoundTransformer) Validate(input any) error

Validate checks if input is valid

func (*RoundTransformer) Version

func (t *RoundTransformer) Version() string

Version returns the transformer version

type SchemaDefinition

type SchemaDefinition struct {
	Fields map[string]*SchemaRule `json:"fields"`
}

SchemaDefinition defines the schema that maps field names to rules.

type SchemaRule

type SchemaRule struct {
	Type      string   `json:"type"`                 // "string", "number", "bool", "array", "object"
	Required  bool     `json:"required,omitempty"`   // whether field must be present
	MinLength *int     `json:"min_length,omitempty"` // string min length
	MaxLength *int     `json:"max_length,omitempty"` // string max length
	Min       *float64 `json:"min,omitempty"`        // numeric minimum
	Max       *float64 `json:"max,omitempty"`        // numeric maximum
	Pattern   string   `json:"pattern,omitempty"`    // regex pattern for strings
	Enum      []string `json:"enum,omitempty"`       // allowed values
	Default   any      `json:"default,omitempty"`    // default value if missing
}

SchemaRule defines a single field validation rule within a schema.

type SchemaValidatorTransformer

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

SchemaValidatorTransformer validates a map against a schema definition. If a field is missing and has a Default, the default is applied. Returns the (possibly amended) data or an error listing all violations.

func NewSchemaValidatorTransformer

func NewSchemaValidatorTransformer(schema *SchemaDefinition) *SchemaValidatorTransformer

NewSchemaValidatorTransformer creates a schema validator.

func (*SchemaValidatorTransformer) Category

func (t *SchemaValidatorTransformer) Category() string

func (*SchemaValidatorTransformer) Description

func (t *SchemaValidatorTransformer) Description() string

func (*SchemaValidatorTransformer) Name

func (*SchemaValidatorTransformer) Transform

func (t *SchemaValidatorTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*SchemaValidatorTransformer) Validate

func (t *SchemaValidatorTransformer) Validate(input any) error

func (*SchemaValidatorTransformer) Version

func (t *SchemaValidatorTransformer) Version() string

type SetFieldTransformer

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

SetFieldTransformer sets (or overwrites) a field in a map to a fixed value.

func NewSetFieldTransformer

func NewSetFieldTransformer(field string, value any) *SetFieldTransformer

NewSetFieldTransformer creates a transformer that sets a field to a fixed value.

func (*SetFieldTransformer) Category

func (t *SetFieldTransformer) Category() string

func (*SetFieldTransformer) Description

func (t *SetFieldTransformer) Description() string

func (*SetFieldTransformer) Name

func (t *SetFieldTransformer) Name() string

func (*SetFieldTransformer) Transform

func (t *SetFieldTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*SetFieldTransformer) Validate

func (t *SetFieldTransformer) Validate(input any) error

func (*SetFieldTransformer) Version

func (t *SetFieldTransformer) Version() string

type SetValueTransformer

type SetValueTransformer struct{}

SetValueTransformer replaces any input with a constant value read from the transform context parameter "value". This is used by the rule engine to set a field to a specific value when a rule matches.

ctx.Set("value", "high")
result, _ := t.Transform(ctx, "old")  // result = "high"

func NewSetValueTransformer

func NewSetValueTransformer() *SetValueTransformer

NewSetValueTransformer creates a set_value transformer.

func (*SetValueTransformer) Category

func (t *SetValueTransformer) Category() string

func (*SetValueTransformer) Description

func (t *SetValueTransformer) Description() string

func (*SetValueTransformer) Name

func (t *SetValueTransformer) Name() string

func (*SetValueTransformer) Transform

func (t *SetValueTransformer) Transform(ctx *TransformContext, _ any) (any, error)

func (*SetValueTransformer) Validate

func (t *SetValueTransformer) Validate(_ any) error

func (*SetValueTransformer) Version

func (t *SetValueTransformer) Version() string

type SplitTransformer

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

SplitTransformer splits a string into parts by delimiter

func NewSplitTransformer

func NewSplitTransformer(delimiter string) *SplitTransformer

NewSplitTransformer creates a new split transformer

func (*SplitTransformer) Category

func (t *SplitTransformer) Category() string

Category returns the transformer category

func (*SplitTransformer) Description

func (t *SplitTransformer) Description() string

Description returns transformer description

func (*SplitTransformer) Name

func (t *SplitTransformer) Name() string

Name returns the transformer name

func (*SplitTransformer) Transform

func (t *SplitTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the split transformation

func (*SplitTransformer) Validate

func (t *SplitTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*SplitTransformer) Version

func (t *SplitTransformer) Version() string

Version returns the transformer version

type Stage

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

Stage represents a single stage in a pipeline

func NewStage

func NewStage(name, executor string) *Stage

NewStage creates a new pipeline stage

func (*Stage) Dependencies

func (s *Stage) Dependencies() []string

func (*Stage) DependsOn

func (s *Stage) DependsOn(stages ...string) *Stage

func (*Stage) Description

func (s *Stage) Description() string

func (*Stage) ErrorHandling

func (s *Stage) ErrorHandling() ErrorHandling

func (*Stage) Executor

func (s *Stage) Executor() string

func (*Stage) IsAsync

func (s *Stage) IsAsync() bool

func (*Stage) Name

func (s *Stage) Name() string

Getter methods

func (*Stage) Params

func (s *Stage) Params() map[string]any

func (*Stage) Retries

func (s *Stage) Retries() int

func (*Stage) Timeout

func (s *Stage) Timeout() time.Duration

func (*Stage) WithAsync

func (s *Stage) WithAsync(async bool) *Stage

func (*Stage) WithDescription

func (s *Stage) WithDescription(desc string) *Stage

Setter methods for builder pattern

func (*Stage) WithErrorHandling

func (s *Stage) WithErrorHandling(handling ErrorHandling) *Stage

func (*Stage) WithParam

func (s *Stage) WithParam(key string, value any) *Stage

func (*Stage) WithParams

func (s *Stage) WithParams(params map[string]any) *Stage

func (*Stage) WithRetries

func (s *Stage) WithRetries(retries int) *Stage

func (*Stage) WithTimeout

func (s *Stage) WithTimeout(timeout time.Duration) *Stage

type StageResult

type StageResult struct {
	StageName string
	Status    StageStatus
	Output    any
	Error     error
	Duration  time.Duration
	Retried   int
	StartedAt time.Time
	EndedAt   time.Time
}

StageResult represents the result of executing a stage

func NewStageResult

func NewStageResult(stageName string) *StageResult

NewStageResult creates a new stage result

func (*StageResult) Fail

func (sr *StageResult) Fail(err error)

Fail marks stage as failed

func (*StageResult) IsFailed

func (sr *StageResult) IsFailed() bool

IsFailed returns true if stage failed

func (*StageResult) IsSuccess

func (sr *StageResult) IsSuccess() bool

IsSuccess returns true if stage executed successfully

func (*StageResult) Skip

func (sr *StageResult) Skip()

Skip marks stage as skipped

func (*StageResult) Success

func (sr *StageResult) Success(output any)

Success marks stage as successful

type StageStatus

type StageStatus string

StageStatus represents the status of a pipeline stage

const (
	StagePending StageStatus = "pending"
	StageRunning StageStatus = "running"
	StageSuccess StageStatus = "success"
	StageFailed  StageStatus = "failed"
	StageSkipped StageStatus = "skipped"
)

type SubstringTransformer

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

SubstringTransformer extracts a substring from input

func NewSubstringTransformer

func NewSubstringTransformer(start, end int) *SubstringTransformer

NewSubstringTransformer creates a new substring transformer

func (*SubstringTransformer) Category

func (t *SubstringTransformer) Category() string

Category returns the transformer category

func (*SubstringTransformer) Description

func (t *SubstringTransformer) Description() string

Description returns transformer description

func (*SubstringTransformer) Name

func (t *SubstringTransformer) Name() string

Name returns the transformer name

func (*SubstringTransformer) Transform

func (t *SubstringTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the substring transformation

func (*SubstringTransformer) Validate

func (t *SubstringTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*SubstringTransformer) Version

func (t *SubstringTransformer) Version() string

Version returns the transformer version

type SubtractDurationTransformer

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

SubtractDurationTransformer subtracts a duration from a time

func NewSubtractDurationTransformer

func NewSubtractDurationTransformer(durationStr string) *SubtractDurationTransformer

NewSubtractDurationTransformer creates a new subtract duration transformer

func (*SubtractDurationTransformer) Category

func (t *SubtractDurationTransformer) Category() string

Category returns the transformer category

func (*SubtractDurationTransformer) Description

func (t *SubtractDurationTransformer) Description() string

Description returns transformer description

func (*SubtractDurationTransformer) Name

Name returns the transformer name

func (*SubtractDurationTransformer) Transform

func (t *SubtractDurationTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the duration subtraction

func (*SubtractDurationTransformer) Validate

func (t *SubtractDurationTransformer) Validate(input any) error

Validate checks if input is valid

func (*SubtractDurationTransformer) Version

func (t *SubtractDurationTransformer) Version() string

Version returns the transformer version

type SubtractTransformer

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

SubtractTransformer subtracts a value from the input

func NewSubtractTransformer

func NewSubtractTransformer(value any) *SubtractTransformer

NewSubtractTransformer creates a new subtract transformer

func (*SubtractTransformer) Category

func (t *SubtractTransformer) Category() string

Category returns the transformer category

func (*SubtractTransformer) Description

func (t *SubtractTransformer) Description() string

Description returns transformer description

func (*SubtractTransformer) Name

func (t *SubtractTransformer) Name() string

Name returns the transformer name

func (*SubtractTransformer) Transform

func (t *SubtractTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the subtraction

func (*SubtractTransformer) Validate

func (t *SubtractTransformer) Validate(input any) error

Validate checks if input is valid

func (*SubtractTransformer) Version

func (t *SubtractTransformer) Version() string

Version returns the transformer version

type TemplateTransformer

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

TemplateTransformer renders a Go text/template with the input data. Input must be a map[string]any that is passed as the dot context.

Example:

tmpl := "Hello, {{.name}}!"
input := map[string]any{"name": "Alice"}
→ "Hello, Alice!"

func MustTemplateTransformer

func MustTemplateTransformer(name, tmpl string) *TemplateTransformer

MustTemplateTransformer is like NewTemplateTransformer but panics on error.

func NewTemplateTransformer

func NewTemplateTransformer(name, tmpl string) (*TemplateTransformer, error)

NewTemplateTransformer creates a template transformer with the given template string. Returns an error if the template cannot be parsed.

func (*TemplateTransformer) Category

func (t *TemplateTransformer) Category() string

func (*TemplateTransformer) Description

func (t *TemplateTransformer) Description() string

func (*TemplateTransformer) Name

func (t *TemplateTransformer) Name() string

func (*TemplateTransformer) Transform

func (t *TemplateTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*TemplateTransformer) Validate

func (t *TemplateTransformer) Validate(input any) error

func (*TemplateTransformer) Version

func (t *TemplateTransformer) Version() string

type TokenizeStringTransformer

type TokenizeStringTransformer struct{}

TokenizeStringTransformer replaces input with a random token

func NewTokenizeStringTransformer

func NewTokenizeStringTransformer() *TokenizeStringTransformer

func (*TokenizeStringTransformer) Category

func (t *TokenizeStringTransformer) Category() string

Category returns the transformer category

func (*TokenizeStringTransformer) Description

func (t *TokenizeStringTransformer) Description() string

Description returns transformer description

func (*TokenizeStringTransformer) Name

Name returns the transformer name

func (*TokenizeStringTransformer) Transform

func (t *TokenizeStringTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the transformation

func (*TokenizeStringTransformer) Validate

func (t *TokenizeStringTransformer) Validate(input any) error

Validate checks if the input is valid for this transformer

func (*TokenizeStringTransformer) Version

func (t *TokenizeStringTransformer) Version() string

Version returns the transformer version

type TransformContext

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

TransformContext holds transformation state with Copy-on-Write optimization It is thread-safe and provides a way to create new contexts with additional values without modifying the original context.

func NewTransformContext

func NewTransformContext() *TransformContext

NewTransformContext creates a new empty context

func (*TransformContext) Clear

func (c *TransformContext) Clear()

Clear resets the context by removing all values

func (*TransformContext) Get

func (c *TransformContext) Get(key string) (any, bool)

Get retrieves a value from the context Returns the value and a boolean indicating if the key exists

func (*TransformContext) Set

func (c *TransformContext) Set(key string, value any)

Set adds or updates a value in the context

func (*TransformContext) Size

func (c *TransformContext) Size() int

Size returns the number of entries in the context

func (*TransformContext) WithValue

func (c *TransformContext) WithValue(key string, value any) *TransformContext

WithValue creates a new context with an additional value (Copy-on-Write pattern) The original context is not modified

type TransformMetrics

type TransformMetrics struct {
	// DurationMs is the total transformation duration in milliseconds
	DurationMs float64

	// TransformCount is the number of transformations applied
	TransformCount int

	// CacheHit indicates whether the result was retrieved from cache
	CacheHit bool

	// EnrichmentCount is the number of enrichment operations performed
	EnrichmentCount int
}

TransformMetrics holds performance and operation metrics for a transformation.

type TransformResult

type TransformResult struct {
	// Data holds the transformation output on success, nil on failure
	Data any

	// Error holds any error that occurred during transformation, nil on success
	Error error

	// Metrics holds performance and operation metrics, nil on error results
	Metrics *TransformMetrics
	// contains filtered or unexported fields
}

TransformResult represents the result of a transformation operation. It holds the transformed data, any error that occurred, and metrics about the transformation process.

Use NewSuccessResult() for successful transformations or NewErrorResult() for failures. Check IsSuccess() to determine the outcome.

func NewErrorResult

func NewErrorResult(err error) *TransformResult

NewErrorResult creates a failed transformation result with an error. Use this when a transformation encounters an error. Note: Even if err is nil, this result is still treated as a failure.

Example:

result := NewErrorResult(fmt.Errorf("invalid data format"))

func NewSuccessResult

func NewSuccessResult(data any, metrics *TransformMetrics) *TransformResult

NewSuccessResult creates a successful transformation result with data and metrics. Use this when a transformation completes successfully.

Example:

result := NewSuccessResult(transformedData, &TransformMetrics{
    DurationMs: 15.5,
    TransformCount: 2,
})

func (*TransformResult) IsSuccess

func (r *TransformResult) IsSuccess() bool

IsSuccess returns true if the transformation succeeded. This uses an internal flag set by NewSuccessResult() to distinguish success from failure, even when Error is nil.

type Transformer

type Transformer interface {
	// Name returns the unique identifier for this transformer.
	// Examples: "UpperCase", "Trim", "ValidateEmail"
	// Should be lowercase with no spaces.
	Name() string

	// Version returns the semantic version of this transformer (e.g., "1.0.0").
	// Used for tracking changes and compatibility.
	Version() string

	// Description returns a human-readable description of what this transformer does.
	// Should explain the transformation and any side effects.
	Description() string

	// Category returns the category this transformer belongs to.
	// Examples: "string", "numeric", "datetime", "validation", "normalization", "privacy"
	Category() string

	// Transform applies the transformation to the input using the provided context.
	// The context can be used to store intermediate values or configuration.
	// Returns the transformed output or an error if transformation fails.
	//
	// Implementation notes:
	// - Must be stateless (no instance state modifications)
	// - Must be thread-safe (safe for concurrent calls)
	// - Should handle type mismatches gracefully
	// - Can read from context but should not modify it unless necessary
	Transform(ctx *TransformContext, input any) (any, error)

	// Validate checks if the input is valid for this transformer.
	// This is called before Transform to ensure early error detection.
	// Returns nil if valid, or a ValidationError if invalid.
	//
	// Implementation notes:
	// - Should check type compatibility
	// - Should check value constraints (length, range, format, etc.)
	// - Should return descriptive ValidationError messages
	// - Should not perform actual transformation
	Validate(input any) error
}

Transformer defines the interface for data transformations. All transformers must implement this interface to be used by the framework.

Transformers are pure functions that accept input, apply a transformation, and return the result. They must be stateless and thread-safe.

type TransformerRegistry

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

TransformerRegistry holds registered transformers by name. It is safe for concurrent use.

func NewTransformerRegistry

func NewTransformerRegistry() *TransformerRegistry

NewTransformerRegistry creates a new empty registry

func (*TransformerRegistry) Count

func (r *TransformerRegistry) Count() int

Count returns the number of registered transformers

func (*TransformerRegistry) Get

func (r *TransformerRegistry) Get(name string) (Transformer, error)

Get retrieves a transformer by name

func (*TransformerRegistry) GetByCategory

func (r *TransformerRegistry) GetByCategory(category string) []Transformer

GetByCategory returns all transformers in a given category

func (*TransformerRegistry) List

func (r *TransformerRegistry) List() []string

List returns all registered transformer names

func (*TransformerRegistry) Register

func (r *TransformerRegistry) Register(transformer Transformer) error

Register adds a transformer to the registry

func (*TransformerRegistry) Unregister

func (r *TransformerRegistry) Unregister(name string)

Unregister removes a transformer from the registry

type TrimTransformer

type TrimTransformer struct{}

TrimTransformer removes leading and trailing whitespace

func NewTrimTransformer

func NewTrimTransformer() *TrimTransformer

NewTrimTransformer creates a new trim transformer

func (*TrimTransformer) Category

func (t *TrimTransformer) Category() string

Category returns the transformer category

func (*TrimTransformer) Description

func (t *TrimTransformer) Description() string

Description returns transformer description

func (*TrimTransformer) Name

func (t *TrimTransformer) Name() string

Name returns the transformer name

func (*TrimTransformer) Transform

func (t *TrimTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the trim transformation

func (*TrimTransformer) Validate

func (t *TrimTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*TrimTransformer) Version

func (t *TrimTransformer) Version() string

Version returns the transformer version

type UnflattenTransformer

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

UnflattenTransformer converts a flat map with dot-separated keys back into a nested map.

Example:

{"user.name": "Alice", "user.address.city": "NYC"}
→ {"user": {"name": "Alice", "address": {"city": "NYC"}}}

func NewUnflattenTransformer

func NewUnflattenTransformer(separator string) *UnflattenTransformer

NewUnflattenTransformer creates an unflatten transformer.

func (*UnflattenTransformer) Category

func (t *UnflattenTransformer) Category() string

func (*UnflattenTransformer) Description

func (t *UnflattenTransformer) Description() string

func (*UnflattenTransformer) Name

func (t *UnflattenTransformer) Name() string

func (*UnflattenTransformer) Transform

func (t *UnflattenTransformer) Transform(ctx *TransformContext, input any) (any, error)

func (*UnflattenTransformer) Validate

func (t *UnflattenTransformer) Validate(input any) error

func (*UnflattenTransformer) Version

func (t *UnflattenTransformer) Version() string

type UpperCaseTransformer

type UpperCaseTransformer struct{}

UpperCaseTransformer converts strings to uppercase

func NewUpperCaseTransformer

func NewUpperCaseTransformer() *UpperCaseTransformer

NewUpperCaseTransformer creates a new uppercase transformer

func (*UpperCaseTransformer) Category

func (t *UpperCaseTransformer) Category() string

Category returns the transformer category

func (*UpperCaseTransformer) Description

func (t *UpperCaseTransformer) Description() string

Description returns transformer description

func (*UpperCaseTransformer) Name

func (t *UpperCaseTransformer) Name() string

Name returns the transformer name

func (*UpperCaseTransformer) Transform

func (t *UpperCaseTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform applies the uppercase transformation

func (*UpperCaseTransformer) Validate

func (t *UpperCaseTransformer) Validate(input any) error

Validate checks if input is valid for this transformer

func (*UpperCaseTransformer) Version

func (t *UpperCaseTransformer) Version() string

Version returns the transformer version

type ValidateEmailTransformer

type ValidateEmailTransformer struct{}

ValidateEmailTransformer validates email addresses

func NewValidateEmailTransformer

func NewValidateEmailTransformer() *ValidateEmailTransformer

NewValidateEmailTransformer creates a new email validation transformer

func (*ValidateEmailTransformer) Category

func (t *ValidateEmailTransformer) Category() string

Category returns the transformer category

func (*ValidateEmailTransformer) Description

func (t *ValidateEmailTransformer) Description() string

Description returns transformer description

func (*ValidateEmailTransformer) Name

func (t *ValidateEmailTransformer) Name() string

Name returns the transformer name

func (*ValidateEmailTransformer) Transform

func (t *ValidateEmailTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform validates the email

func (*ValidateEmailTransformer) Validate

func (t *ValidateEmailTransformer) Validate(input any) error

Validate checks if input is valid

func (*ValidateEmailTransformer) Version

func (t *ValidateEmailTransformer) Version() string

Version returns the transformer version

type ValidateIPTransformer

type ValidateIPTransformer struct{}

ValidateIPTransformer validates IP addresses

func NewValidateIPTransformer

func NewValidateIPTransformer() *ValidateIPTransformer

NewValidateIPTransformer creates a new IP validation transformer

func (*ValidateIPTransformer) Category

func (t *ValidateIPTransformer) Category() string

Category returns the transformer category

func (*ValidateIPTransformer) Description

func (t *ValidateIPTransformer) Description() string

Description returns transformer description

func (*ValidateIPTransformer) Name

func (t *ValidateIPTransformer) Name() string

Name returns the transformer name

func (*ValidateIPTransformer) Transform

func (t *ValidateIPTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform validates the IP address

func (*ValidateIPTransformer) Validate

func (t *ValidateIPTransformer) Validate(input any) error

Validate checks if input is valid

func (*ValidateIPTransformer) Version

func (t *ValidateIPTransformer) Version() string

Version returns the transformer version

type ValidatePhoneTransformer

type ValidatePhoneTransformer struct{}

ValidatePhoneTransformer validates phone numbers

func NewValidatePhoneTransformer

func NewValidatePhoneTransformer() *ValidatePhoneTransformer

NewValidatePhoneTransformer creates a new phone validation transformer

func (*ValidatePhoneTransformer) Category

func (t *ValidatePhoneTransformer) Category() string

Category returns the transformer category

func (*ValidatePhoneTransformer) Description

func (t *ValidatePhoneTransformer) Description() string

Description returns transformer description

func (*ValidatePhoneTransformer) Name

func (t *ValidatePhoneTransformer) Name() string

Name returns the transformer name

func (*ValidatePhoneTransformer) Transform

func (t *ValidatePhoneTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform validates the phone number

func (*ValidatePhoneTransformer) Validate

func (t *ValidatePhoneTransformer) Validate(input any) error

Validate checks if input is valid

func (*ValidatePhoneTransformer) Version

func (t *ValidatePhoneTransformer) Version() string

Version returns the transformer version

type ValidateURLTransformer

type ValidateURLTransformer struct{}

ValidateURLTransformer validates URLs

func NewValidateURLTransformer

func NewValidateURLTransformer() *ValidateURLTransformer

NewValidateURLTransformer creates a new URL validation transformer

func (*ValidateURLTransformer) Category

func (t *ValidateURLTransformer) Category() string

Category returns the transformer category

func (*ValidateURLTransformer) Description

func (t *ValidateURLTransformer) Description() string

Description returns transformer description

func (*ValidateURLTransformer) Name

func (t *ValidateURLTransformer) Name() string

Name returns the transformer name

func (*ValidateURLTransformer) Transform

func (t *ValidateURLTransformer) Transform(ctx *TransformContext, input any) (any, error)

Transform validates the URL

func (*ValidateURLTransformer) Validate

func (t *ValidateURLTransformer) Validate(input any) error

Validate checks if input is valid

func (*ValidateURLTransformer) Version

func (t *ValidateURLTransformer) Version() string

Version returns the transformer version

Jump to

Keyboard shortcuts

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