Documentation
¶
Overview ¶
Package sink runs configured sinks. CAN/file/null sinks and MQTT QoS 1 broker acknowledgements 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 ¶
- Variables
- func PostgresDDL(table string, timescaleDB bool) string
- func RetryAfter(err error) (time.Duration, bool)
- type BatchByteLimiter
- type BatchPushReport
- type BatchPusher
- type BroadcastReport
- type Broadcaster
- type ConnectorRegistrar
- type DataServer
- func (d *DataServer) Addr() string
- func (d *DataServer) RemoveRoute(path string)
- func (d *DataServer) SetRoute(path string, h http.Handler)
- func (d *DataServer) Start() error
- func (d *DataServer) State() (string, error)
- func (d *DataServer) Stop(ctx context.Context) error
- func (d *DataServer) WrapListener(ln net.Listener) net.Listener
- type DataServerOption
- type DeliveryClass
- type DeliveryClassifier
- type Pusher
- type ReplayReader
- type Runtime
- type SelectiveBatchPusher
- type WirePusher
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("sink skipped message")
Functions ¶
func PostgresDDL ¶ added in v1.2.5
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.
Types ¶
type BatchByteLimiter ¶ added in v1.2.6
type BatchByteLimiter interface {
BatchMaxBytes() int64
}
BatchByteLimiter lets a batch sink bound the transient request/SQL shape in addition to its message-count maximum. The Connector partitions at an Envelope boundary and always sends at least one entry.
type BatchPushReport ¶ added in v1.2.6
type BatchPushReport struct {
Skipped []bool
}
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 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, options ...DataServerOption) *DataServer
func (*DataServer) Addr ¶
func (d *DataServer) Addr() string
func (*DataServer) RemoveRoute ¶
func (d *DataServer) RemoveRoute(path string)
func (*DataServer) Start ¶
func (d *DataServer) Start() error
func (*DataServer) State ¶ added in v1.2.6
func (d *DataServer) State() (string, error)
State reports whether serve-mode sink routes are currently reachable. A listener failure remains observable while the recovery loop is backing off.
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.
func (*DataServer) WrapListener ¶ added in v1.2.6
func (d *DataServer) WrapListener(ln net.Listener) net.Listener
WrapListener applies the process connection policy supplied by App. TCP sinks use it too, so their accepted clients share the same descriptor budget as admin and HTTP data traffic. A nil DataServer is the standalone/no-policy case used by tests and embeddings.
type DataServerOption ¶ added in v1.2.6
type DataServerOption func(*DataServer)
func WithListenerWrapper ¶ added in v1.2.6
func WithListenerWrapper(wrapper func(net.Listener) net.Listener) DataServerOption
WithListenerWrapper applies wrapper to every initial or recovered listener. App uses this seam to share one accepted-connection budget with its admin server; standalone tests and embeddings can omit it.
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 ¶
Pusher sinks confirm each delivery (for example CAN writes or MQTT broker PUBACKs). ErrSkip means "cannot carry this message, count it and move on" (e.g. an 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 SelectiveBatchPusher ¶ added in v1.2.6
type SelectiveBatchPusher interface {
BatchSize() int
PushBatchSelective(ctx context.Context, entries []queue.Entry) (BatchPushReport, error)
}
SelectiveBatchPusher amortizes one durable flush across an ordered group while preserving permanent per-envelope skip reporting. A nil error confirms every non-skipped entry and Skipped must have len(entries).