core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCommands

func InitCommands(conn adbc.Connection, c *config.Conf) error

func InitTables

func InitTables(conn adbc.Connection, c *config.Conf) error

InitTables creates the tables that live across the pipeline's lifetime, such as the aggregate tables a tumbling window manager maintains.

func InitUDFs

func InitUDFs(c *config.Conf) error

InitUDFs reports that a config declares UDFs, which turbine does not support. The Python engine registers arbitrary Python callables through conn.create_function; Go has no equivalent, and rather than inventing a plugin mechanism, user-defined functions are left to DuckDB itself (a macro, an extension, or an ATTACHed database that defines them).

This is an error rather than a silent skip: ignoring the block would defer the failure to an unhelpful binder error when the handler SQL calls the function.

Types

type ErrorPolicy

type ErrorPolicy int
const (
	PolicyRaise ErrorPolicy = iota
	PolicyIgnore
	PolicyDLQ
)

func ParseErrorPolicy

func ParseErrorPolicy(s string) (ErrorPolicy, error)

ParseErrorPolicy resolves the configured policy name. Matching the Python engine, the name is case-insensitive and an empty value means RAISE.

type Handler

type Handler interface {
	Init(ctx context.Context) error
	Write(msg []byte) error
	Invoke(ctx context.Context) (arrow.Table, error)
}

type Message

type Message struct {
	Value     []byte
	Topic     string
	Partition int32
	Offset    int64
}

Message is one record from a source, with whatever provenance the source knows about it. Only Kafka populates the metadata fields.

func (Message) HasMetadata

func (m Message) HasMetadata() bool

HasMetadata reports whether the source supplied provenance for this message. Topic is the discriminator: a Kafka record always has one, and a source that has none leaves it empty.

type MetadataWriter

type MetadataWriter interface {
	WriteMessage(msg Message) error
}

MetadataWriter is implemented by handlers that can use a message's source metadata. Handlers that only need the payload implement Handler alone and the consume loop hands them the value.

type Metrics

type Metrics struct {
	MessageCount           metric.Int64Counter
	ErrorCount             metric.Int64Counter
	SourceReadLatency      metric.Float64Histogram
	SinkFlushLatency       metric.Float64Histogram
	SinkFlushNumRows       metric.Int64Gauge
	SinkFlushCount         metric.Int64Counter
	BatchProcessingLatency metric.Float64Histogram
}

Metrics holds the instruments the pipeline records, mirroring the names, descriptions and units the Python engine exports.

func NewMetrics

func NewMetrics(mp metric.MeterProvider) (*Metrics, error)

NewMetrics builds the instruments from a meter provider. Passing a noop provider yields instruments that record nothing, so the pipeline needs no nil checks.

type PipelineErrorPolicies

type PipelineErrorPolicies struct {
	Policy  ErrorPolicy
	DLQSink Sink
}

type Sink

type Sink interface {
	WriteTable(batch arrow.Table) error
	Flush() error
	Batch() (arrow.Table, error)
}

type Source

type Source interface {
	Start() error
	Stream() <-chan []Message
	Commit() error
	Close() error
}

type Stats

type Stats struct {
	StartTime time.Time
	NumErrors int
	// contains filtered or unexported fields
}

func (*Stats) AddMessagesConsumed

func (s *Stats) AddMessagesConsumed(n int64)

func (*Stats) GetThroughput

func (s *Stats) GetThroughput() float64

func (*Stats) MessagesConsumed

func (s *Stats) MessagesConsumed() int64

func (*Stats) SetNumMessagesConsumed

func (s *Stats) SetNumMessagesConsumed(num int64)

func (*Stats) SetThroughput

func (s *Stats) SetThroughput(throughput float64)

type Turbine

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

func NewTurbine

func NewTurbine(
	source Source,
	handler Handler,
	sink Sink,
	batchSize int,
	flushInterval time.Duration,
	lock *sync.Mutex,
	policy PipelineErrorPolicies,
	opts ...TurbineOption,
) *Turbine

func (*Turbine) ConsumeLoop

func (t *Turbine) ConsumeLoop(ctx context.Context, maxMsgs int) (stats *Stats, err error)

func (*Turbine) StatusLoop

func (t *Turbine) StatusLoop(ctx context.Context) error

type TurbineOption

type TurbineOption func(turbine *Turbine)

func WithMetrics

func WithMetrics(m *Metrics) TurbineOption

WithMetrics records pipeline instruments through the given provider.

func WithTurbineLogger

func WithTurbineLogger(l *zap.Logger) TurbineOption

Jump to

Keyboard shortcuts

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