cutover

package
v0.1.56 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalModeLocal = "local"
	SignalModeRedis = "redis"

	BlockerClusterSchemaUnavailable     = "cluster_schema_unavailable"
	BlockerClusterControlUnavailable    = "cluster_control_unavailable"
	BlockerLegacyRunsNonterminal        = "legacy_runs_nonterminal"
	BlockerLegacyDeliveriesPending      = "legacy_deliveries_pending"
	BlockerLegacyTerminalHistoryInvalid = "legacy_terminal_history_invalid"
	BlockerLegacyEventPayloadInvalid    = "legacy_event_payload_invalid"
	BlockerDatabaseClientsActive        = "database_clients_active"
	BlockerClusterMembersRegistered     = "cluster_members_registered"
	BlockerCurrentSchemaMismatch        = "current_schema_mismatch"
	BlockerCurrentContractMismatch      = "current_contract_mismatch"
	BlockerReplicasUnavailable          = "replicas_unavailable"
	BlockerReplicasUnexpected           = "replicas_unexpected"
	BlockerMemberReleaseMismatch        = "member_release_mismatch"
	BlockerMemberSchemaMismatch         = "member_schema_mismatch"
	BlockerMemberContractMismatch       = "member_contract_mismatch"
	BlockerMemberSchemaChecksumMismatch = "member_schema_checksum_mismatch"
	BlockerMemberNotReady               = "member_not_ready"
	BlockerSignalDependencyUnavailable  = "signal_dependency_unavailable"
	BlockerReleaseIdentityMissing       = "release_identity_missing"
	BlockerExpectedReplicasInvalid      = "expected_replicas_invalid"
	BlockerClusterVersionConflict       = "cluster_version_conflict"
	BlockerCutoverIDMismatch            = "cutover_id_mismatch"
	BlockerTransitionNotAllowed         = "transition_not_allowed"
	BlockerDatabaseUnavailable          = "database_unavailable"
	BlockerRuntimeRunsNonterminal       = "runtime_runs_nonterminal"
	BlockerMaintenance                  = "maintenance"
)

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

func IsBlocked

func IsBlocked(err error) bool

Types

type Blocker

type Blocker struct {
	Code            string `json:"code"`
	Scope           string `json:"scope"`
	ID              string `json:"id,omitempty"`
	MessageRedacted string `json:"message_redacted,omitempty"`
}

Blocker is deliberately safe to expose to administrators and automation. It contains stable machine codes and redacted evidence, never payloads, credentials, database error strings, or Run input/output.

type Control

type Control struct {
	Mode              string     `json:"mode"`
	ExpectedReplicas  int32      `json:"expected_replicas"`
	CutoverID         uuid.UUID  `json:"cutover_id"`
	DrainStartedAt    *time.Time `json:"drain_started_at,omitempty"`
	DrainDeadlineAt   *time.Time `json:"drain_deadline_at,omitempty"`
	HardMaintenanceAt time.Time  `json:"hard_maintenance_at"`
	ReopenedAt        *time.Time `json:"reopened_at,omitempty"`
	Version           int64      `json:"version"`
	UpdatedAt         time.Time  `json:"updated_at"`
}

type Current

type Current struct {
	SchemaVersion         int32  `json:"schema_version"`
	SchemaChecksum        string `json:"schema_checksum"`
	MigrationName         string `json:"migration_name,omitempty"`
	RuntimeContractID     string `json:"runtime_contract_id"`
	RuntimeContractDigest string `json:"runtime_contract_digest"`
	ReleaseID             string `json:"release_id"`
	GitSHA                string `json:"git_sha"`
}

type DatabaseEvidence

type DatabaseEvidence struct {
	OtherClientBackends int64 `json:"other_client_backends"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) Register

func (h *Handler) Register(api *echo.Group, jwtMiddleware, adminMiddleware echo.MiddlewareFunc)

Register exposes evidence only. Maintenance mutations remain CLI-only so a compromised browser session cannot drain or reopen the runtime cluster.

func (*Handler) Status

func (h *Handler) Status(c echo.Context) error

type Identity

type Identity struct {
	ReleaseID             string
	GitSHA                string
	SchemaVersion         int32
	SchemaChecksum        string
	MigrationName         string
	RuntimeContractID     string
	RuntimeContractDigest string
}

type LegacyEvidence

type LegacyEvidence struct {
	RunsTablePresent              bool  `json:"runs_table_present"`
	NonterminalRuns               int64 `json:"nonterminal_runs"`
	PendingWebhookDeliveries      int64 `json:"pending_webhook_deliveries"`
	PendingRunDeliveries          int64 `json:"pending_run_deliveries"`
	PendingTaskCallbackDeliveries int64 `json:"pending_task_callback_deliveries"`
	InvalidTerminalRuns           int64 `json:"invalid_terminal_runs"`
	InvalidRunEventPayloads       int64 `json:"invalid_run_event_payloads"`
}

func (LegacyEvidence) PendingDeliveries

func (e LegacyEvidence) PendingDeliveries() int64

type Member

type Member struct {
	InstanceID            uuid.UUID `json:"instance_id"`
	ReleaseID             string    `json:"release_id"`
	GitSHA                string    `json:"git_sha"`
	SchemaVersion         int32     `json:"schema_version"`
	SchemaChecksum        string    `json:"schema_checksum"`
	RuntimeContractID     string    `json:"runtime_contract_id"`
	RuntimeContractDigest string    `json:"runtime_contract_digest"`
	StartedAt             time.Time `json:"started_at"`
	LastSeenAt            time.Time `json:"last_seen_at"`
	Live                  bool      `json:"live"`
	Draining              bool      `json:"draining"`
	Ready                 bool      `json:"ready"`
}

type OperationError

type OperationError struct {
	Code string
}

func (*OperationError) Error

func (e *OperationError) Error() string

type PreflightOptions

type PreflightOptions struct {
	RequireExclusive bool
	RequireNoMembers bool
}

type Readiness

type Readiness struct {
	Ready    bool      `json:"ready"`
	Blockers []Blocker `json:"blockers"`
}

type Report

type Report struct {
	DatabaseTime           time.Time           `json:"database_time"`
	SchemaInstalled        bool                `json:"runtime_schema_installed"`
	Control                *Control            `json:"control,omitempty"`
	Current                Current             `json:"current"`
	Members                []Member            `json:"members"`
	Legacy                 *LegacyEvidence     `json:"legacy,omitempty"`
	Database               DatabaseEvidence    `json:"database"`
	Retirement             *RetirementEvidence `json:"retirement,omitempty"`
	Readiness              Readiness           `json:"readiness"`
	ReopenReadiness        *Readiness          `json:"reopen_readiness,omitempty"`
	SignalBus              SignalBus           `json:"signal_bus"`
	Changed                bool                `json:"changed,omitempty"`
	RuntimeUninstalledNoop bool                `json:"runtime_uninstalled_noop,omitempty"`
}

func (Report) MarshalJSON

func (r Report) MarshalJSON() ([]byte, error)

type RetirementEvidence

type RetirementEvidence struct {
	LiveWindowMilliseconds int64 `json:"live_window_ms"`
	MembersBefore          int64 `json:"members_before"`
	LiveMembers            int64 `json:"live_members"`
	StaleMembers           int64 `json:"stale_members"`
	RetiredStaleMembers    int64 `json:"retired_stale_members"`
	MembersAfter           int64 `json:"members_after"`
}

type RetirementOptions

type RetirementOptions struct {
	AllowRuntimeUninstalledNoop bool
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(pool *pgxpool.Pool, cfg ServiceConfig) *Service

func (*Service) Drain

func (s *Service) Drain(ctx context.Context, req TransitionRequest) (Report, error)

func (*Service) HardMaintenance

func (s *Service) HardMaintenance(ctx context.Context, req TransitionRequest) (Report, error)

func (*Service) Preflight

func (s *Service) Preflight(ctx context.Context, opts PreflightOptions) (Report, error)

func (*Service) Reopen

func (s *Service) Reopen(ctx context.Context, req TransitionRequest) (Report, error)

func (*Service) RetireStaleMembers

func (s *Service) RetireStaleMembers(ctx context.Context, opts RetirementOptions) (Report, error)

RetireStaleMembers removes abandoned membership rows only after proving that this command is the sole database client and no member is still live. The follow-up migration preflight remains the authoritative exclusivity gate.

func (*Service) Status

func (s *Service) Status(ctx context.Context) (Report, error)

type ServiceConfig

type ServiceConfig struct {
	Identity     Identity
	SignalMode   string
	SignalHealth SignalHealth
	LiveWindow   time.Duration
}

type SignalBus

type SignalBus struct {
	Mode    string `json:"mode"`
	Healthy bool   `json:"healthy"`
}

type SignalHealth

type SignalHealth interface {
	Health(context.Context) error
}

type TransitionRequest

type TransitionRequest struct {
	ExpectedVersion             int64
	ExpectedReplicas            int32
	CutoverID                   uuid.UUID
	DrainDeadline               *time.Time
	AllowRuntimeUninstalledNoop bool
}

Jump to

Keyboard shortcuts

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