doctor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 25 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 doctor is `muster doctor` (C-02.FR-14, FR-15): it checks the database, its schema version, its connections, the Keyring and the clock, prints one line per check as `OK|WARN|FAIL <check>: <detail>` and reports whether any check failed. It only reads: both connections it opens run every statement in a read-only transaction, and it takes no --actor. It checks every Mattermost Connection and Destination as their checks do, in the background client class (C-13.FR-10), every Telegram Connection with the steps of its check — the dry probe, getMe, getWebhookInfo — and every Telegram Destination with its Destination check — getChat and getChatMember in the channel and its discussion group — printing the failing step with its message (C-14.FR-11, FR-14), and every Bridge and Slack Connection and Destination with theirs (C-22.FR-2, FR-3, C-24.FR-2, FR-3). `muster dev doctor` sends a Slack Connection's requests where `muster dev` sends them, so that the published tokens of the fake Slack server never reach slack.com.

Index

Constants

View Source
const (
	CheckDatabase          = "database"
	CheckPostgreSQLVersion = "postgresql_version"
	CheckSchema            = "schema"
	CheckSessionConnection = "session_connection"
	CheckTLSMain           = "tls_main"
	CheckTLSSession        = "tls_session"
	CheckKeyCanary         = "key_canary"
	CheckKeyring           = "keyring"
	CheckClockSkew         = "clock_skew"
	// CheckConnections fails when the Organizations, an Organization's outbound address policy, or its Connections and
	// Destinations cannot be read; the policy is read for every Organization, with Connections or without, and when it
	// fails that Organization is not checked. Each Connection and Destination checked prints its own line,
	// "connection <name>" or "destination <name>".
	CheckConnections = "connections"
)

The checks, in the order they are printed.

Variables

This section is empty.

Functions

func Run

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

Run runs every check and prints its line. It returns false when a check failed, and an error when the settings cannot be read.

Types

type Conn

type Conn interface {
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}

Conn is what the checks need of a connection; *pgx.Conn and *pgxpool.Conn implement it.

type Connections

type Connections struct {
	Main    Conn
	Session SessionConn
	Close   func()
}

Connections are the main and the session connection; Close closes both.

func Open

func Open(ctx context.Context, cfg config.Config) (Connections, error)

Open opens the main pool and takes one connection of it, then the session connection, and makes every transaction of both read-only.

type Opener

type Opener func(ctx context.Context, cfg config.Config) (Connections, error)

Opener opens the two connections of cfg. The error of an unreachable connection names which one it is.

type Options

type Options struct {
	// Environ is the environment in the form of os.Environ; only MUSTER_* variables are read.
	Environ []string
	// Out receives the lines.
	Out io.Writer
	// Development is `muster dev doctor`, which accepts the published development key like the server does in
	// development mode.
	Development bool
	// contains filtered or unexported fields
}

Options are what the CLI gives the doctor.

type Result

type Result struct {
	Status Status
	Check  string
	Detail string
}

Result is one printed line.

func (Result) String

func (r Result) String() string

type SessionConn

type SessionConn interface {
	Conn
	WaitForNotification(ctx context.Context) (*pgconn.Notification, error)
}

SessionConn is the session connection, which also receives notifications.

type Status

type Status string

Status is the outcome of one check.

const (
	OK   Status = "OK"
	Warn Status = "WARN"
	Fail Status = "FAIL"
)

Jump to

Keyboard shortcuts

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