transformer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnonRuleParser added in v0.8.4

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

AnonRuleParser is a wrapper around a transformer rule parser that fetches and converts anon extension security labels into transformation rules before validation is performed

func NewAnonRuleParser added in v0.8.4

func NewAnonRuleParser(ctx context.Context, pgURL string, dumpToFile bool, logger loglib.Logger, parser ParseFn) (*AnonRuleParser, error)

NewAnonRuleParser is a wrapper around a parser that fetches and converts anon extension security labels into transformation rules before validation is performed

func (*AnonRuleParser) Close added in v0.8.4

func (a *AnonRuleParser) Close() error

func (*AnonRuleParser) ParseAndValidate added in v0.8.4

func (a *AnonRuleParser) ParseAndValidate(ctx context.Context, rules Rules) (*TransformerMap, error)

ParseAndValidate will fetch the anon masking rules from the source database and convert them into transformation rules before passing them to the wrapped parser for validation.

type ColumnTransformers added in v0.5.0

type ColumnTransformers map[string]transformers.Transformer

type Config

type Config struct {
	InferFromSecurityLabels bool
	DumpInferredRules       bool
	TransformerRules        []TableRules
	ValidationMode          string
}

func (*Config) HasNoRules added in v0.9.4

func (c *Config) HasNoRules() bool

type Option

type Option func(t *Transformer)

func WithLogger

func WithLogger(l loglib.Logger) Option

func WithParser added in v0.5.0

func WithParser(parser ParseFn) Option

type ParseFn added in v0.5.0

type ParseFn func(ctx context.Context, rules Rules) (*TransformerMap, error)

type PostgresTransformerParser added in v0.5.0

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

func NewPostgresTransformerParser added in v0.5.0

func NewPostgresTransformerParser(ctx context.Context, pgURL string, builder transformerBuilder, requiredTables []string) (*PostgresTransformerParser, error)

func (*PostgresTransformerParser) Close added in v0.5.0

func (v *PostgresTransformerParser) Close() error

func (*PostgresTransformerParser) ParseAndValidate added in v0.5.0

func (v *PostgresTransformerParser) ParseAndValidate(ctx context.Context, rules Rules) (*TransformerMap, error)

type Rules

type Rules struct {
	Transformers   []TableRules `yaml:"transformations"`
	ValidationMode string       `yaml:"validation_mode"`
}

type TableRules

type TableRules struct {
	Schema         string                      `yaml:"schema"`
	Table          string                      `yaml:"table"`
	ColumnRules    map[string]TransformerRules `yaml:"column_transformers"`
	ValidationMode string                      `yaml:"validation_mode"`
}

type Transformer

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

Transformer is a decorator around a wal processor that transforms wal event column values following the configured transformation rules.

func New

func New(ctx context.Context, cfg *Config, processor processor.Processor, builder transformerBuilder, opts ...Option) (*Transformer, error)

New will return a transformer processor wrapper that will transform incoming wal event column values as configured by the transformation rules.

func (*Transformer) Close

func (t *Transformer) Close() error

func (*Transformer) Name

func (t *Transformer) Name() string

func (*Transformer) ProcessWALEvent

func (t *Transformer) ProcessWALEvent(ctx context.Context, event *wal.Event) error

type TransformerMap added in v1.0.1

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

TransformerMap holds the active and noop transformers for each table/column combination. It is not concurrency safe.

func NewTransformerMap added in v1.0.1

func NewTransformerMap() *TransformerMap

NewTransformerMap initializes and returns a new instance of TransformerMap.

func (*TransformerMap) AddActiveTransformer added in v1.0.1

func (tm *TransformerMap) AddActiveTransformer(schema, table, column string, transformer transformers.Transformer)

AddActiveTransformer adds an active transformer for the specified schema, table, and column.

func (*TransformerMap) AddNoopTransformer added in v1.0.1

func (tm *TransformerMap) AddNoopTransformer(schema, table, column string)

AddNoopTransformer adds a noop transformer for the specified schema, table, and column.

func (*TransformerMap) Close added in v1.0.1

func (tm *TransformerMap) Close() error

Close closes all active transformers in the map and aggregates and returns any errors that occur during closing.

func (*TransformerMap) GetActiveColumnTransformers added in v1.0.1

func (tm *TransformerMap) GetActiveColumnTransformers(schema, table string) (ColumnTransformers, bool)

GetActiveColumnTransformers retrieves the active column transformers for the specified schema and table. Does not include noop transformers.

func (*TransformerMap) GetAllColumnTransformers added in v1.0.1

func (tm *TransformerMap) GetAllColumnTransformers(schema, table string) (ColumnTransformers, bool)

GetAllColumnTransformers retrieves all column transformers (active and noop) for the specified schema and table. If no transformers are found, it returns false.

func (*TransformerMap) GetNoopColumnTransformers added in v1.0.1

func (tm *TransformerMap) GetNoopColumnTransformers(schema, table string) (ColumnTransformers, bool)

GetNoopColumnTransformers retrieves the noop column transformers for the specified schema and table. Does not include active transformers.

type TransformerRules

type TransformerRules struct {
	Name              string         `yaml:"name"`
	Parameters        map[string]any `yaml:"parameters"`
	DynamicParameters map[string]any `yaml:"dynamic_parameters"`
}

Jump to

Keyboard shortcuts

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