check

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package check provides various configuration and health checks that can be run against a sql.DB connection.

Index

Constants

This section is empty.

Variables

View Source
var ErrReplicaNotHealthy = fmt.Errorf("replica is not healthy")

ErrReplicaNotHealthy is returned when a replica's IO or SQL thread is not running.

Functions

func RunChecks

func RunChecks(ctx context.Context, r Resources, logger *slog.Logger, scope ScopeFlag) error

RunChecks runs all checks that are registered for the given scope. Checks run in name order so that a statement failing more than one check always reports the same error.

Types

type Resources

type Resources struct {
	DB                   *sql.DB
	Replicas             []*sql.DB
	Table                *table.TableInfo
	Statement            *statement.AbstractStatement
	TargetChunkTime      time.Duration
	Threads              int
	ReplicaMaxLag        time.Duration
	SkipDropAfterCutover bool
	ForceKill            bool
	// The following resources are only used by the
	// pre-run checks
	Host               string
	Username           string
	Password           string
	TLSMode            string
	TLSCertificatePath string
	// GTID, when true, opts the migration into the experimental GTID-based
	// change source. The configuration check uses this to additionally
	// validate gtid_mode and enforce_gtid_consistency on the source.
	GTID bool
}

type ScopeFlag

type ScopeFlag uint8

ScopeFlag scopes a check

const (
	ScopeNone        ScopeFlag = 0
	ScopePreRun      ScopeFlag = 1 << 0
	ScopePreflight   ScopeFlag = 1 << 1
	ScopePostSetup   ScopeFlag = 1 << 2
	ScopeCutover     ScopeFlag = 1 << 3
	ScopePostCutover ScopeFlag = 1 << 4
	ScopeTesting     ScopeFlag = 1 << 5
	// ScopeStatement marks preflight checks that classify the ALTER statement
	// itself: they decide from the parsed statement alone whether Spirit
	// refuses to run it, never touching a database connection. Callers can run
	// them via RunChecks with only Resources.Statement set (Table is optional
	// and widens coverage when present) to determine up front that a statement
	// would be refused — for example, a planning tool classifying DDL before
	// an apply. Passing these checks is not a promise Spirit will accept the
	// statement: checks that need a live connection (existing foreign keys,
	// triggers, privileges, ...) still run only at preflight. A check tagged
	// with this scope must tolerate every Resources field except Statement
	// being unset.
	ScopeStatement ScopeFlag = 1 << 6
)

Jump to

Keyboard shortcuts

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