sinks

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRetryMaxAttempts    = 4
	DefaultRetryInitialBackoff = 100 * time.Millisecond
	DefaultRetryMaxBackoff     = 2 * time.Second
	DefaultRetryDeadline       = 10 * time.Second
)

Retry defaults. Deliberately short: the point is to absorb a hiccup, not to wait out an outage. A destination that is still refusing after a few seconds is better reported, because the exit code says "retryable" and a supervisor restarts the pipeline anyway.

Retrying is on by default. Before this, one refused connection killed the process, which cost a cold start, a group rejoin and a rebalance to recover from a blip. That default was the defect, not a safe baseline.

Variables

This section is empty.

Functions

func New

func New(sink config.Sink, conn adbc.Connection, opts ...Option) (core.Sink, error)

func NewWithContext added in v1.0.5

func NewWithContext(ctx context.Context, sink config.Sink, conn adbc.Connection, opts ...Option) (core.Sink, error)

NewWithContext builds a sink and wraps it in a retry ladder where one helps.

Not every sink is wrapped. The Kafka sink hands records to franz-go, which already retries a produce with its own backoff; a second ladder on top of that one delays the report without improving delivery. The console, noop and sqlcommand sinks reach nothing that can be temporarily unavailable -- the sqlcommand sink writes through the pipeline's own DuckDB connection, and a failure there is not a network blip.

That leaves the sinks that cross a network to somebody else's server.

Types

type ClickhouseSink

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

ClickhouseSink inserts result batches into a ClickHouse table.

The Python sink hands the Arrow table to clickhouse_connect's insert_arrow, which maps Arrow columns to table columns by name. clickhouse-go has no Arrow entry point, so the batch is unpacked into rows against an explicit column list taken from the Arrow schema, which preserves that name-based mapping.

func NewClickhouseSink

func NewClickhouseSink(conf config.ClickhouseSink) (*ClickhouseSink, error)

func (*ClickhouseSink) Batch

func (s *ClickhouseSink) Batch() (arrow.Table, error)

Batch returns nothing. The Python ClickhouseSink alone among the sinks reports no batch: rows go straight to ClickHouse and are not held for a downstream reader.

func (*ClickhouseSink) Close

func (s *ClickhouseSink) Close() error

func (*ClickhouseSink) Flush

func (s *ClickhouseSink) Flush(ctx context.Context) error

func (*ClickhouseSink) Probe added in v1.0.5

func (s *ClickhouseSink) Probe(ctx context.Context) error

Probe dials the server. clickhouse.Open only validates options, so this is the first time the pipeline learns whether the destination is there.

func (*ClickhouseSink) WriteTable

func (s *ClickhouseSink) WriteTable(ctx context.Context, batch arrow.Table) error

type ConsoleSink

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

ConsoleSink writes each result row to stdout as a JSON object.

func NewConsoleSink

func NewConsoleSink() *ConsoleSink

func NewConsoleSinkTo

func NewConsoleSinkTo(w io.Writer) *ConsoleSink

func (*ConsoleSink) Batch

func (s *ConsoleSink) Batch() (arrow.Table, error)

func (*ConsoleSink) Flush

func (s *ConsoleSink) Flush(ctx context.Context) error

func (*ConsoleSink) WriteTable

func (s *ConsoleSink) WriteTable(ctx context.Context, batch arrow.Table) error

type IcebergSink

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

IcebergSink appends result batches to an Iceberg table.

func NewIcebergSink

func NewIcebergSink(ctx context.Context, catalogName, tableName string) (*IcebergSink, error)

func (*IcebergSink) Batch

func (s *IcebergSink) Batch() (arrow.Table, error)

func (*IcebergSink) Flush

func (s *IcebergSink) Flush(ctx context.Context) error

func (*IcebergSink) WriteTable

func (s *IcebergSink) WriteTable(ctx context.Context, batch arrow.Table) error

type KafkaSink

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

KafkaSink produces one message per result row, JSON encoded, matching the Python KafkaSink.

func NewKafkaSink

func NewKafkaSink(conf config.KafkaSink) (*KafkaSink, error)

func (*KafkaSink) Batch

func (s *KafkaSink) Batch() (arrow.Table, error)

func (*KafkaSink) Close

func (s *KafkaSink) Close() error

func (*KafkaSink) Flush

func (s *KafkaSink) Flush(ctx context.Context) error

Flush blocks until every buffered record has been acknowledged, so a batch is durable before its source offsets are committed.

func (*KafkaSink) WriteTable

func (s *KafkaSink) WriteTable(ctx context.Context, batch arrow.Table) error

type NoopSink

type NoopSink struct{}

func (*NoopSink) Batch

func (n *NoopSink) Batch() (arrow.Table, error)

func (*NoopSink) Flush

func (n *NoopSink) Flush(ctx context.Context) error

func (*NoopSink) WriteTable

func (n *NoopSink) WriteTable(ctx context.Context, batch arrow.Table) error

type Option added in v1.0.5

type Option func(*options)

Option configures how a sink is built.

func WithMeterProvider added in v1.0.5

func WithMeterProvider(mp metric.MeterProvider) Option

WithMeterProvider supplies the provider the retry counter records through. Without one the counter records nothing, which is what a pipeline started with no --metrics wants.

type Prober added in v1.0.5

type Prober interface {
	Probe(ctx context.Context) error
}

Prober is implemented by a sink that can check its destination before the first batch arrives.

Without it a sink only discovers its destination when a batch reaches it. clickhouse.Open validates options and never dials, so a pipeline whose DSN names a host that does not resolve starts normally, logs "consumer loop starting", and runs. With a long flush interval the failure appears minutes later, and a supervisor calls the pipeline healthy for all of them.

type RetryPolicy added in v1.0.5

type RetryPolicy struct {
	MaxAttempts    int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
	Deadline       time.Duration
}

RetryPolicy bounds how long a sink keeps trying a destination that is not answering.

Deadline bounds the whole ladder rather than one attempt, and it is the field that matters most. The retry runs inside the pipeline's open state transaction, and DuckDB's now() returns that transaction's start time, so a ladder that outlives the flush interval freezes the window clock -- the bug #158 fixed, reached by a second route.

func RetryPolicyFrom added in v1.0.5

func RetryPolicyFrom(c *config.SinkRetry) RetryPolicy

RetryPolicyFrom resolves a config block into a policy, filling in defaults for anything the user left out.

func (RetryPolicy) Enabled added in v1.0.5

func (p RetryPolicy) Enabled() bool

Enabled reports whether the policy will ever make a second attempt.

type SQLCommandSink

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

SQLCommandSink materializes the result batch as a table and runs arbitrary DuckDB SQL against it. This is how the Python engine writes parquet, S3, Postgres, DuckLake and MotherDuck outputs.

func NewSQLCommandSink

func NewSQLCommandSink(conn adbc.Connection, sql string, substitutions []config.SQLCommandSubstitution) (*SQLCommandSink, error)

func (*SQLCommandSink) Batch

func (s *SQLCommandSink) Batch() (arrow.Table, error)

func (*SQLCommandSink) Flush

func (s *SQLCommandSink) Flush(ctx context.Context) error

func (*SQLCommandSink) WriteTable

func (s *SQLCommandSink) WriteTable(ctx context.Context, batch arrow.Table) error

Jump to

Keyboard shortcuts

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