SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then
Posted: 2026-09-12 · Report this thread
brandon Site Admin brandon profile Posts: 677

client.System() names the singleton system: no I/O, no failure, and no name, because one schema is one installation. Register declares the system’s own knobs, the built-in alert schedules and the metrics collector, and is safe to run on every startup. A stream’s Register creates the system with defaults if it is absent, so most programs never call it.

err := client.System().Register(ctx, &sqlstreams.SystemConfig{
	PartitionCountAlert: &sqlstreams.PartitionCountAlertConfig{ScheduleExpression: "0 * * * *"},
	MetricCollector:    &sqlstreams.MetricCollectorWorkerConfig{PollRate: 10 * time.Second},
})
if err != nil {
	return err
}

Verbs

verbreturnsnotes
Register(ctx, cfg)errorcreates the schema and the control-plane tables when missing (SQL0064 when the role cannot); nil cfg is the defaults; a differing redeclaration replaces the stored worker rows
Get(ctx)*Systemthe comma-ok read: (nil, nil) when no system is registered
Migrate(ctx, targetVersion)errormoves the control-plane tables to a version (migrations)
MigrationVersion(ctx)int64the version the control-plane tables are at; ErrNotRegistered
MigrateStreams(ctx, targetVersion)errormoves every registered stream to a version
Destroy(ctx, options)errordeletes every stream, schedule, consumer group, worker, and the control-plane tables; ErrDestroyDisabled unless ClientConfig.AllowDestroy; ErrSystemLive and ErrStreamsRegistered unless DestroyOptions.Force
Bindings(ctx)[]*Bindingevery group’s effective binding set and any declarer still waiting, ordered by stream then group; a group reading the whole stream does not appear
Metrics()*SystemMetricsHandleno I/O; Metrics
Alerts()*SystemAlertsHandleno I/O; Alerts

CLI

sqlstreams system get reads the system registration. Add --quiet for an existence check: no output, exit 0 when registered, exit 1 when absent. --output json returns the system row, or null with exit 1 when absent; it cannot be combined with --quiet.

sqlstreams system binding list reads System().Bindings() across the installation. Use sqlstreams consumer binding get orders.created billing for one consumer’s binding declaration.

Config

SystemConfig

fielddefaultwhat it decides
PartitionCountAlertits own defaultsthe partition_count check: ScheduleExpression (@every 1m), Threshold (0, half the lock ceiling Postgres reports), PendingDuration and MaximumGap (two minutes each), and DisablePending (false)
CompactionReadCostAlertits own defaultsthe compaction_read_cost check; ScheduleExpression defaults to @every 1m; PendingDuration and MaximumGap default to two minutes; DisablePending defaults to false
WorkerLivenessAlertits own defaultsthe worker_liveness check; ScheduleExpression defaults to @every 1m; PendingDuration and MaximumGap default to two minutes; DisablePending defaults to false
MetricCollectorProgressAlertits own defaultsthe system-owned collector-progress check; fields below
MetricCollectorPollRate: 30show often the collector’s measurement pass runs; zero is the default, negative is rejected

A running collector keeps its rate until its next claim; restart the manager to apply a new one immediately.

MetricCollectorProgressAlertConfig

fielddefaultwhat it decides
ScheduleExpression@every 1mhow often collector progress is checked
MaximumAge0zero uses max(two minutes, three declared collector poll intervals); a positive duration overrides it
PendingDuration2mrequired unhealthy duration during continuous manager lease coverage
DisablePendingfalsepermits immediate activation with current manager lease coverage

The default age follows the current collector declaration. An already-running collector keeps its previously claimed rate until its next claim.

Gotchas

  • The system is a singleton and a handle anyway. The day that changes, the API grows by one parameter, client.System(name), and client.Stream[T](name) stays the default system’s shortcut.
  • The manager is not here. It is a running subsystem with its own handle, client.Manager() (Manager).