processor

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity added in v2.6.0

type Activity struct {
	Stage     string        `json:"stage"`
	Statement int64         `json:"statement,omitempty"`
	Table     string        `json:"table,omitempty"`
	FirstRow  int           `json:"firstRow,omitempty"`
	Rows      int           `json:"rows,omitempty"`
	StartedAt time.Time     `json:"startedAt"`
	Elapsed   time.Duration `json:"elapsed"`
}

Activity describes a pipeline stage without SQL text, row values, templates, or error messages. Statement is a one-based framed statement number (including passthrough SQL and trailing trivia). FirstRow and Rows refer to an INSERT.

type ColumnSchema

type ColumnSchema struct {
	Type  *types.FieldType
	Index int
	Name  string
}

type PreparedColumnOp added in v2.3.0

type PreparedColumnOp struct {
	Type             string              // "template" or "json"
	CompiledTemplate *templates.Template // for type "template"
	JsonFields       []jsonFieldOp       // for type "json"
}

type PreparedTableConfig

type PreparedTableConfig struct {
	Skip                          bool
	ColumnOps                     map[string][]PreparedColumnOp
	ColumnTemplates               map[string][]*templates.Template
	ColumnVariableTemplates       map[string]*templates.Template
	ColumnVariableDepsPerTemplate map[*templates.Template][]*templates.Template
	GlobalVariables               map[string]string
	TableVariables                map[string]string
	RowVariableTemplates          []*templates.Template
}

type Processor

type Processor struct {
	Config config.Config
	// contains filtered or unexported fields
}

func NewProcessor

func NewProcessor(config config.Config) (*Processor, error)

func NewProcessorWithConfig

func NewProcessorWithConfig(configData config.Config) (*Processor, error)

func (*Processor) Process

func (p *Processor) Process(input io.Reader, output io.Writer, parent context.Context) (resultErr error)

Process transforms SQL in input order. Concurrent calls on the same Processor return an error. Streams remain open on success. On cancellation/error, Process closes streams implementing io.Closer to interrupt blocked I/O; output implementing Abort() is aborted instead, without flushing buffered data. Non-closable streams must be interruptible by their caller if they can block. Process joins all pipeline goroutines before returning. Failed output is partial.

func (*Processor) ProcessedTables added in v2.4.0

func (p *Processor) ProcessedTables() []string

ProcessedTables returns a sorted list of all table names encountered in CREATE TABLE statements during the most recent Process() call. Must be called after Process() returns.

func (*Processor) Progress added in v2.6.0

func (p *Processor) Progress() Progress

Progress can be polled concurrently with Process, including while I/O or a template function is blocked. It never waits for those operations or calls user logging code. Before the first run State is idle; each accepted run resets all statistics. A rejected concurrent Process call leaves them alone. The returned snapshot is independent and may be modified by the caller.

type Progress added in v2.6.0

type Progress struct {
	State               string        `json:"state"` // idle, running, stopping, completed, failed, canceled
	StartedAt           time.Time     `json:"startedAt"`
	FinishedAt          time.Time     `json:"finishedAt"`
	Elapsed             time.Duration `json:"elapsed"`
	BytesRead           int64         `json:"bytesRead"`
	BytesWritten        int64         `json:"bytesWritten"`
	StatementsRead      int64         `json:"statementsRead"`
	StatementsCompleted int64         `json:"statementsCompleted"`
	StatementsSkipped   int64         `json:"statementsSkipped"`
	RowsTransformed     int64         `json:"rowsTransformed"`
	LastTable           string        `json:"lastTable,omitempty"` // last identified table, not necessarily the current read
	LastReadAt          time.Time     `json:"lastReadAt"`
	LastWriteAt         time.Time     `json:"lastWriteAt"`
	InFlightBytes       int64         `json:"inFlightBytes"`
	InFlightLimit       int64         `json:"inFlightLimit"`
	Reader              Activity      `json:"reader"`
	Writer              Activity      `json:"writer"`
	Workers             []Activity    `json:"workers"` // index is the worker ID
	Failure             *Activity     `json:"failure,omitempty"`
}

Progress is a point-in-time view of a Process call. Counts include only bytes delivered by Read / accepted by Write; buffered or remote destinations may not have flushed, persisted, or imported them. RowsTransformed counts rows in successfully transformed INSERTs, even if a later output write fails. InFlightBytes is the charged raw-input budget, not heap usage or process RSS. Worker activities can overlap and their elapsed times must not be summed as wall time. Reading/writing means an I/O call is active, not proof of a stall.

type TableSchema

type TableSchema struct {
	Columns columnMap
	Name    string
}

Jump to

Keyboard shortcuts

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