normalize

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package normalize provides normalizers that convert raw source bytes into structured core.Record values ready for storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSV

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

CSV normalizer converts CSV rows into structured records.

func NewCSV

func NewCSV() *CSV

NewCSV creates a CSV normalizer with default configuration.

func NewCSVWithConfig

func NewCSVWithConfig(cfg CSVConfig) *CSV

NewCSVWithConfig creates a CSV normalizer with explicit configuration.

func (*CSV) Close

func (c *CSV) Close() error

Close finalizes the normalizer (processes any remaining buffered data).

func (*CSV) Ingest

func (c *CSV) Ingest(raw []byte) ([]core.Record, error)

Ingest parses CSV data and returns normalized records.

func (*CSV) Init

func (c *CSV) Init(run *core.Run) error

Init initializes the normalizer (extracts headers if needed).

type CSVConfig

type CSVConfig struct {
	Delimiter   rune     // field delimiter (default: ',')
	HasHeaders  bool     // first row contains column names
	ColumnNames []string // explicit column names (overrides headers)
	TrimSpace   bool     // trim whitespace from fields
}

CSVConfig defines CSV parsing behavior.

func DefaultCSVConfig

func DefaultCSVConfig() CSVConfig

DefaultCSVConfig returns standard CSV parsing defaults.

type LineJSON

type LineJSON struct{}

LineJSON is a normalizer that wraps each raw line in a minimal JSON record with a "line" payload field. It is the default normalizer for interactive captures.

func NewLineJSON

func NewLineJSON() *LineJSON

NewLineJSON returns a new LineJSON normalizer.

func (*LineJSON) Close

func (l *LineJSON) Close() error

Close satisfies the Normalizer interface; LineJSON holds no resources.

func (*LineJSON) Ingest

func (l *LineJSON) Ingest(b []byte) ([]core.Record, error)

Ingest wraps the raw bytes in a single Record with a "line" payload field.

func (*LineJSON) Init

func (l *LineJSON) Init(*core.Run) error

Init satisfies the Normalizer interface; LineJSON requires no initialization.

type Normalizer

type Normalizer interface {
	Init(run *core.Run) error
	Ingest(raw []byte) ([]core.Record, error)
	Close() error
}

Normalizer converts raw source bytes into one or more structured Records. Implementations are stateful: Init is called once at the start of a run, Ingest is called per frame, and Close is called when the source is exhausted.

type Raw

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

Raw normalizer converts raw text lines into records. This is useful for log files, plain text data, or any unstructured content.

func NewRaw

func NewRaw() *Raw

NewRaw creates a raw normalizer with default configuration.

func NewRawWithConfig

func NewRawWithConfig(cfg RawConfig) *Raw

NewRawWithConfig creates a raw normalizer with explicit configuration.

func (*Raw) Close

func (r *Raw) Close() error

Close finalizes the normalizer (processes any remaining buffered data).

func (*Raw) Ingest

func (r *Raw) Ingest(raw []byte) ([]core.Record, error)

Ingest processes raw bytes and returns normalized records.

func (*Raw) Init

func (r *Raw) Init(run *core.Run) error

Init initializes the normalizer.

type RawConfig

type RawConfig struct {
	RecordType   string // record type to assign (default: "raw")
	TrimSpace    bool   // trim whitespace from lines
	SkipEmpty    bool   // skip empty lines
	PreserveRaw  bool   // include raw line in payload
	SplitOnLines bool   // split on newlines (default: true)
}

RawConfig defines raw text parsing behavior.

func DefaultRawConfig

func DefaultRawConfig() RawConfig

DefaultRawConfig returns standard raw parsing defaults.

Jump to

Keyboard shortcuts

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