switchover

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateChannel   = "goalert_switchover_state"
	ControlChannel = "goalert_switchover_control"
)
View Source
const (
	StateStarting  = State("starting")
	StateReady     = State("ready")
	StateArmed     = State("armed")
	StateArmWait   = State("armed-waiting")
	StatePausing   = State("pausing")
	StatePaused    = State("paused")
	StatePauseWait = State("paused-waiting")
	StateComplete  = State("complete")
	StateAbort     = State("aborted")
)

Possible states

Variables

This section is empty.

Functions

func CalcDBOffset

func CalcDBOffset(ctx context.Context, db *sql.DB) (time.Duration, error)

Types

type App

type App interface {
	Pause(context.Context) error
	Resume()
	Status() lifecycle.Status
}

type DeadlineConfig

type DeadlineConfig struct {
	BeginAt          time.Time     // The start-time of the Switch-Over.
	ConsensusTimeout time.Duration // Amount of time to wait for consensus amongst all nodes before aborting.
	PauseDelay       time.Duration // How long to wait after starting before beginning the global pause.
	PauseTimeout     time.Duration // Timeout to achieve global pause before aborting.
	MaxPause         time.Duration // Absolute maximum amount of time for any operation to be delayed due to the Switch-Over.
	NoPauseAPI       bool          // Allow HTTP/API requests during Pause phase.
}

DeadlineConfig controls the timeing of a Switch-Over operation.

func ConfigFromContext

func ConfigFromContext(ctx context.Context) DeadlineConfig

ConfigFromContext returns the DeadlineConfig associated with the current context.

func DefaultConfig

func DefaultConfig() DeadlineConfig

DefaultConfig returns the default deadline configuration.

func ParseDeadlineConfig

func ParseDeadlineConfig(s string, offset time.Duration) (*DeadlineConfig, error)

ParseDeadlineConfig will parse deadline configuration (given by Serialize) from a string. Offset should be the time difference between the local clock and the central clock (i.e. Postgres).

func (DeadlineConfig) AbsoluteDeadline

func (cfg DeadlineConfig) AbsoluteDeadline() time.Time

AbsoluteDeadline will calculate the absolute deadline of the entire switchover operation.

func (DeadlineConfig) ConsensusDeadline

func (cfg DeadlineConfig) ConsensusDeadline() time.Time

ConsensusDeadline will return the deadline for consensus amonst all nodes.

func (DeadlineConfig) PauseAt

func (cfg DeadlineConfig) PauseAt() time.Time

PauseAt will return the time global pause begins.

func (DeadlineConfig) PauseDeadline

func (cfg DeadlineConfig) PauseDeadline() time.Time

PauseDeadline will return the deadline to achieve global pause.

func (DeadlineConfig) Serialize

func (cfg DeadlineConfig) Serialize(offset time.Duration) string

Serialize returns a textual representation of DeadlineConfig that can be transmitted to other nodes. Offset should be time difference between the local clock and the central clock (i.e. Postgres).

type Handler

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

func NewHandler

func NewHandler(ctx context.Context, oldC, newC driver.Connector, oldURL, newURL string) (*Handler, error)

func (*Handler) Abort

func (h *Handler) Abort()

func (*Handler) Connect

func (h *Handler) Connect(ctx context.Context) (c driver.Conn, err error)

func (*Handler) DB

func (h *Handler) DB() *sql.DB

func (*Handler) Driver

func (h *Handler) Driver() driver.Driver

func (*Handler) SetApp

func (h *Handler) SetApp(app App)

func (*Handler) Status

func (h *Handler) Status() *Status

type State

type State string

State indicates the current state of a node.

func (State) IsActive

func (s State) IsActive() bool

IsActive will return true if the state represents an on-going change-over event.

type Status

type Status struct {
	NodeID string
	State  State
	Offset time.Duration
	At     time.Time

	ActiveRequests int
	// contains filtered or unexported fields
}

Status represents the status of an individual node.

func ParseStatus

func ParseStatus(str string) (*Status, error)

func (Status) MatchDBNext

func (s Status) MatchDBNext(dbNextURL string) bool

MatchDBNext will return true if the Status indicates a matching db-next-url.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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