sink

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 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

Overview

Package sink runs configured sinks. CAN/file/null sinks push-confirm each message, HTTP POST and PostgreSQL sinks confirm batches, and serve-mode HTTP/TCP sinks broadcast to connected clients, with replay served straight from connector queues (SSE/WS only).

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = errors.New("sink skipped message")

Functions

func PostgresDDL added in v1.2.5

func PostgresDDL(table string, timescaleDB bool) string

PostgresDDL returns the exact copy/paste schema shown to operators and run by auto-create mode. TimescaleDB must already be installed in the target database; when enabled, the final statement idempotently converts the table into a hypertable using observed_at as its time dimension.

func RetryAfter added in v1.2.4

func RetryAfter(err error) (time.Duration, bool)

RetryAfter returns a server-requested minimum retry delay carried by err. Sinks use this seam to communicate protocol-native backoff without coupling connectors to HTTP response types.

Types

type BatchPusher added in v1.2.4

type BatchPusher interface {
	BatchSize() int
	PushBatch(ctx context.Context, entries []queue.Entry) error
}

BatchPusher confirms an ordered group of queue entries as one sink write. BatchSize is the maximum number of entries the connector should provide; short batches are valid and are delivered without waiting for the batch to fill. A nil error confirms every entry in the supplied batch.

type BroadcastReport

type BroadcastReport struct {
	Accepted       []bool
	RecipientDrops int64
	Err            error
}

type Broadcaster

type Broadcaster interface {
	Broadcast(entries []queue.Entry) BroadcastReport
}

Broadcaster sinks fan out to connected clients without confirmation.

type ConnectorRegistrar

type ConnectorRegistrar interface {
	RegisterConnector(id string, r ReplayReader)
	UnregisterConnector(id string)
}

ConnectorRegistrar lets connectors attach their queue for client replay.

type DataServer

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

DataServer hosts serve-mode sink endpoints with dynamically managed routes.

func NewDataServer

func NewDataServer(addr string, log *slog.Logger) *DataServer

func (*DataServer) Addr

func (d *DataServer) Addr() string

func (*DataServer) RemoveRoute

func (d *DataServer) RemoveRoute(path string)

func (*DataServer) SetRoute

func (d *DataServer) SetRoute(path string, h http.Handler)

func (*DataServer) Start

func (d *DataServer) Start() error

func (*DataServer) Stop

func (d *DataServer) Stop(ctx context.Context) error

Stop cancels all active request contexts (ending SSE/WS streams), then shuts the server down, waiting for handlers up to ctx's deadline.

type DeliveryClass

type DeliveryClass string
const (
	DeliveryConfirmed  DeliveryClass = "confirmed"
	DeliveryResumable  DeliveryClass = "resumable"
	DeliveryBestEffort DeliveryClass = "best_effort"
	DeliveryObserved   DeliveryClass = "observe_only"
)

func DeliveryClassOf

func DeliveryClassOf(r Runtime) DeliveryClass

type DeliveryClassifier

type DeliveryClassifier interface {
	DeliveryClass() DeliveryClass
}

DeliveryClassifier makes the route boundary explicit. Implementations that do not provide it are classified from their Pusher/Broadcaster seam by DeliveryClassOf.

type Pusher

type Pusher interface {
	Push(ctx context.Context, e *msg.Envelope) error
}

Pusher sinks confirm each delivery (CAN). ErrSkip means "cannot carry this message, count it and move on" (e.g. envelope without raw bytes).

type ReplayReader

type ReplayReader interface {
	Read(ctx context.Context, after int64, limit int) ([]queue.Entry, error)
}

ReplayReader is what serve-mode sinks use to replay history for a client.

type Runtime

type Runtime interface {
	ID() string
	Stop()
	State() (string, error)
}

func New

func New(ctx context.Context, cfg model.Sink, mgr *bus.Manager, ds *DataServer, log *slog.Logger, met *metrics.Set) (Runtime, error)

type WirePusher

type WirePusher interface {
	PushWire(ctx context.Context, e *msg.Envelope) error
}

WirePusher preserves the envelope's original N2K source identity and raw payload instead of re-originating it through Beacon's claimed client.

Jump to

Keyboard shortcuts

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