runtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 63 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 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

View Source
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
)
View Source
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.

View Source
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

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

func MeasureSkew(ctx context.Context, q rowQuerier, realClock clock.Clock) (time.Duration, error)

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

func Migrate(ctx context.Context, opts Options) error

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

func ReplayIngest(ctx context.Context, opts Options, r IngestReplay) (ingest.Replayed, error)

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

func ResetPassword(ctx context.Context, opts Options, r PasswordReset) (string, error)

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

func ResetTOTP(ctx context.Context, opts Options, r TOTPReset) (string, bool, error)

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

func RotateKey(ctx context.Context, opts Options, r KeyRotation) (keyring.Rotated, error)

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.

func Run

func Run(ctx context.Context, opts Options) error

Run is the server: it starts in order and serves until ctx ends, then shuts down within the grace period and returns nil. A failure during startup or a listener that stops is returned; the caller exits non-zero.

Types

type IngestReplay

type IngestReplay struct {
	Since       time.Duration
	SinceText   string
	Integration string
	Actor       string
}

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

type KeyRotation struct {
	KeyID string
	Actor string
}

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

type PasswordReset struct {
	Actor    string
	Login    string
	Password logging.Secret
}

PasswordReset is what `muster admin reset-password` asks for: the --actor name, the login and the new password.

type TOTPReset

type TOTPReset struct {
	Actor string
	Login string
}

TOTPReset is what `muster admin reset-totp` asks for: the --actor name and the login.

Jump to

Keyboard shortcuts

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