Documentation
¶
Overview ¶
Package runtime wires the process: the server command, `muster migrate` and Muster inside `muster dev`. It owns the start-up order — settings, logger, the Keyring, connections and checks, migrations when enabled, the schema version check, the key canary and the start-up ensure steps (the partitions among them) under the migration lock, the replica key record, the listeners, then the Leader lock keeper, the clock skew check and the live updates — and the graceful shutdown on SIGTERM (C-02.FR-16).
Index ¶
- Constants
- func Callbacks(rec requestlog.InboundRecorder, realClock clock.Clock, ...) http.Handler
- func MeasureSkew(ctx context.Context, q rowQuerier, realClock clock.Clock) (time.Duration, error)
- func Migrate(ctx context.Context, opts Options) error
- func ReplayIngest(ctx context.Context, opts Options, r IngestReplay) (ingest.Replayed, error)
- func ResetPassword(ctx context.Context, opts Options, r PasswordReset) (string, error)
- func ResetTOTP(ctx context.Context, opts Options, r TOTPReset) (string, bool, error)
- func RotateKey(ctx context.Context, opts Options, r KeyRotation) (keyring.Rotated, error)
- func Run(ctx context.Context, opts Options) error
- type IngestReplay
- type KeyRotation
- type Options
- type PasswordReset
- type TOTPReset
Constants ¶
const ( // ClockSkewWarning is process.clock_skew_warning: a larger skew against the database clock is logged as // clock_skew. ClockSkewWarning = 2 * time.Second // SkewInterval is how often each replica measures its clock skew. SkewInterval = time.Minute )
const InfoRefreshInterval = time.Minute
InfoRefreshInterval is how often muster_integration_info and muster_route_info are read again from the database besides the hints of changes, which repairs a refresh that failed.
const ShutdownGrace = 20 * time.Second
ShutdownGrace is process.shutdown_grace: from SIGTERM to exit, inside the chart's 30 s termination grace period.
Variables ¶
This section is empty.
Functions ¶
func Callbacks ¶
func Callbacks(rec requestlog.InboundRecorder, realClock clock.Clock, mm mattermost.CallbackConfig, tg telegram.WebhookConfig, br bridge.PushConfig, sl slack.CallbackConfig) http.Handler
Callbacks is the callback mux of the ingest listener: the button presses of Mattermost Connections (C-13.FR-4), on every method, since the callback answers each request 200 with an empty JSON object; the webhook of Telegram Connections in the webhook update mode (C-14.FR-1), on POST; the events of Bridge Connections in push mode (bridgeEvent, C-22.FR-11), on POST; and the presses of Slack Connections in http mode (slackInteraction, C-24.FR-9), on POST. The API's request validation never sees them: each handler decides every answer. Each of the four callbacks is wrapped by requestlog.Inbound, which hands to rec, timed on realClock, every request its handler annotates with a known Connection, refused ones included, once the answer is sent (C-23.FR-1).
func MeasureSkew ¶
MeasureSkew compares the real clock with the database's clock_timestamp(), read halfway through the round trip: the result is positive when the replica's clock is ahead. It takes two samples and keeps the one with the shorter round trip, so that opening a pool connection for the first does not skew the result.
func Migrate ¶
Migrate is `muster migrate`: settings, logger, the master keys, connections and checks, then the migrations under the migration lock. It refuses keys the server refuses, except the development key, which only the server command checks for. It takes no --actor (C-02.FR-15).
func ReplayIngest ¶
ReplayIngest is `muster ingest replay` (C-06.FR-17, C-02.FR-15): settings, logger, connections and checks and the schema version check, then the Stored Snapshots of the period set back to pending in one transaction, recorded in the Audit log with the --actor name; the processing workers of the running replicas process them again. It needs no master key: the Keyring is not opened.
func ResetPassword ¶
ResetPassword is `muster admin reset-password` (C-03.FR-11): settings, logger, connections and checks and the schema version check, then the reset of the account's password in the Organization, recorded in the Audit log with the --actor name. It returns the public_id of the account. It needs no master key: the Keyring is not opened.
func ResetTOTP ¶
ResetTOTP is `muster admin reset-totp` (C-03.FR-11): settings, logger, connections and checks and the schema version check, then the removal of the account's TOTP and recovery codes in the Organization, which ends its sessions and is recorded in the Audit log with the --actor name. It returns the public_id of the account and whether it had TOTP. It needs no master key: the Keyring is not opened.
func RotateKey ¶
RotateKey is `muster secrets rotate-key` (C-20.FR-7, C-02.FR-15): settings, logger, the master keys — refused as the server refuses them — connections and checks and the schema version check, then, under the migration lock, the key canary check and the activation of the key (keyring.Rotation). The refusals — a key this process does not hold (keyring.ErrKeyNotHeld) and live replicas that lack it (*keyring.ReplicasLackKeyError) — are returned as they are. The command renders nothing: the Leader of the running replicas re-renders the open Root messages.
Types ¶
type IngestReplay ¶
IngestReplay is what `muster ingest replay` asks for: the period, as a duration and as given, the name of one Integration or empty for all, and the --actor name.
type KeyRotation ¶
KeyRotation is what `muster secrets rotate-key` asks for: the id of the key to activate and the --actor name.
type Options ¶
type Options struct {
// Environ is the environment in the form of os.Environ; only MUSTER_* variables are read.
Environ []string
// Stdout receives the log lines.
Stdout io.Writer
// Development is `muster dev`: the schema is migrated on start whatever MUSTER_MIGRATE_ON_START says, and the
// published development key is accepted.
Development bool
// contains filtered or unexported fields
}
Options are what the process gives the runtime.
type PasswordReset ¶
PasswordReset is what `muster admin reset-password` asks for: the --actor name, the login and the new password.