sink

package
v0.0.0-...-2c2f5ba Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sink defines the Sink interface and implementations for writing processed records out of the StreamForge pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSink

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

FileSink writes records to a file, one record per line.

func NewFileSink

func NewFileSink(path string) *FileSink

NewFileSink creates a sink that appends records to the given file path.

func (*FileSink) Close

func (f *FileSink) Close() error

Close closes the file.

func (*FileSink) Flush

func (f *FileSink) Flush(_ context.Context) error

Flush syncs the file to disk.

func (*FileSink) Open

func (f *FileSink) Open(_ context.Context) error

Open opens the file for writing (creates or appends).

func (*FileSink) Write

func (f *FileSink) Write(_ context.Context, r *record.Record) error

Write appends a record to the file.

type KafkaSink

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

KafkaSink writes records to a Kafka topic.

func NewKafkaSink

func NewKafkaSink(cfg KafkaSinkConfig) *KafkaSink

NewKafkaSink creates a new Kafka producer sink.

func (*KafkaSink) Close

func (k *KafkaSink) Close() error

Close shuts down the Kafka writer.

func (*KafkaSink) Flush

func (k *KafkaSink) Flush(_ context.Context) error

Flush is handled by the writer's batching mechanism.

func (*KafkaSink) Open

func (k *KafkaSink) Open(_ context.Context) error

Open creates the Kafka writer.

func (*KafkaSink) Write

func (k *KafkaSink) Write(ctx context.Context, r *record.Record) error

Write sends a record to Kafka.

type KafkaSinkConfig

type KafkaSinkConfig struct {
	Brokers []string
	Topic   string
	Async   bool
}

KafkaSinkConfig holds configuration for a Kafka sink.

type MemorySink

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

MemorySink collects records in memory. Useful for testing.

func NewMemorySink

func NewMemorySink() *MemorySink

NewMemorySink creates a new in-memory sink for testing.

func (*MemorySink) Close

func (m *MemorySink) Close() error

Close is a no-op.

func (*MemorySink) Flush

func (m *MemorySink) Flush(_ context.Context) error

Flush is a no-op.

func (*MemorySink) Open

func (m *MemorySink) Open(_ context.Context) error

Open is a no-op.

func (*MemorySink) Records

func (m *MemorySink) Records() []*record.Record

Records returns a copy of all collected records.

func (*MemorySink) Reset

func (m *MemorySink) Reset()

Reset clears all collected records.

func (*MemorySink) Write

func (m *MemorySink) Write(_ context.Context, r *record.Record) error

Write appends the record to the in-memory collection.

type Sink

type Sink interface {
	// Open initializes the sink.
	Open(ctx context.Context) error
	// Write outputs a single record.
	Write(ctx context.Context, record *record.Record) error
	// Flush ensures all buffered writes are committed.
	Flush(ctx context.Context) error
	// Close releases resources.
	Close() error
}

Sink is the interface for writing processed records to an external system.

type StdoutOption

type StdoutOption func(*StdoutSink)

StdoutOption configures the stdout sink.

func WithWriter

func WithWriter(w io.Writer) StdoutOption

WithWriter sets a custom writer instead of os.Stdout.

type StdoutSink

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

StdoutSink writes records to standard output (or a configurable writer).

func NewStdoutSink

func NewStdoutSink(opts ...StdoutOption) *StdoutSink

NewStdoutSink creates a sink that writes records to stdout.

func (*StdoutSink) Close

func (s *StdoutSink) Close() error

Close is a no-op for stdout.

func (*StdoutSink) Flush

func (s *StdoutSink) Flush(_ context.Context) error

Flush is a no-op for stdout.

func (*StdoutSink) Open

func (s *StdoutSink) Open(_ context.Context) error

Open is a no-op.

func (*StdoutSink) Write

func (s *StdoutSink) Write(_ context.Context, r *record.Record) error

Write outputs the record as "key: value" to the writer.

Jump to

Keyboard shortcuts

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