System
Edit this pageclient.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
| verb | returns | notes |
|---|---|---|
Register(ctx, cfg) | error | creates 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) | *System | the comma-ok read: (nil, nil) when no system is registered |
Migrate(ctx, targetVersion) | error | moves the control-plane tables to a version (migrations) |
MigrationVersion(ctx) | int64 | the version the control-plane tables are at; ErrNotRegistered |
MigrateStreams(ctx, targetVersion) | error | moves every registered stream to a version |
Destroy(ctx, options) | error | deletes every stream, schedule, consumer group, worker, and the control-plane tables; ErrDestroyDisabled unless ClientConfig.AllowDestroy; ErrSystemLive and ErrStreamsRegistered unless DestroyOptions.Force |
Bindings(ctx) | []*Binding | every 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() | *SystemMetricsHandle | no I/O; Metrics |
Alerts() | *SystemAlertsHandle | no 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
| field | default | what it decides |
|---|---|---|
PartitionCountAlert | its own defaults | the partition_count check: ScheduleExpression (@every 1m), Threshold (0, half the lock ceiling Postgres reports), PendingDuration and MaximumGap (two minutes each), and DisablePending (false) |
CompactionReadCostAlert | its own defaults | the compaction_read_cost check; ScheduleExpression defaults to @every 1m; PendingDuration and MaximumGap default to two minutes; DisablePending defaults to false |
WorkerLivenessAlert | its own defaults | the worker_liveness check; ScheduleExpression defaults to @every 1m; PendingDuration and MaximumGap default to two minutes; DisablePending defaults to false |
MetricCollectorProgressAlert | its own defaults | the system-owned collector-progress check; fields below |
MetricCollector | PollRate: 30s | how 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
| field | default | what it decides |
|---|---|---|
ScheduleExpression | @every 1m | how often collector progress is checked |
MaximumAge | 0 | zero uses max(two minutes, three declared collector poll intervals); a positive duration overrides it |
PendingDuration | 2m | required unhealthy duration during continuous manager lease coverage |
DisablePending | false | permits 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), andclient.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).