app

package
v0.0.0-...-2a6bc2c Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CauseManual means switchover was issued via command line
	CauseManual = "manual"
	// CauseWorker means switchover was initated via MDB worker (set directly to dcs)
	CauseWorker = "worker"
	// CauseAuto  means failover was started automatically by failure detection process
	CauseAuto = "auto"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is main application structure

func NewApp

func NewApp(configFile, logLevel string) (*App, error)

NewApp is an App constructor

func (*App) CliAbort

func (app *App) CliAbort() int

CliAbort cleans switchover node from DCS

func (*App) CliDisableMaintenance

func (app *App) CliDisableMaintenance(waitTimeout time.Duration) int

CliDisableMaintenance disables maintenance mode

func (*App) CliEnableMaintenance

func (app *App) CliEnableMaintenance(waitTimeout time.Duration) int

CliEnableMaintenance enables maintenance mode

func (*App) CliGetMaintenance

func (app *App) CliGetMaintenance() int

CliGetMaintenance prints on/off depending on current maintenance status

func (*App) CliHostAdd

func (app *App) CliHostAdd(host string, priority *int, dryRun bool, skipRedisCheck bool) int

CliHostAdd add hosts to the list of hosts in dcs

func (*App) CliHostList

func (app *App) CliHostList() int

CliHostList prints list of hosts from dcs

func (*App) CliHostRemove

func (app *App) CliHostRemove(host string) int

CliHostRemove removes host from the list of hosts in dcs

func (*App) CliInfo

func (app *App) CliInfo(verbose bool) int

CliInfo prints DCS-based shard state to stdout

func (*App) CliState

func (app *App) CliState(verbose bool) int

CliState prints state of the shard to the stdout

func (*App) CliSwitch

func (app *App) CliSwitch(switchFrom, switchTo string, waitTimeout time.Duration) int

CliSwitch performs manual switch-over of the master node

func (*App) GetActiveNodes

func (app *App) GetActiveNodes() ([]string, error)

GetActiveNodes returns a list of active nodes from DCS

func (*App) GetMaintenance

func (app *App) GetMaintenance() (*Maintenance, error)

GetMaintenance returns current maintenance status from dcs

func (*App) Run

func (app *App) Run() int

Run enters the main application loop

type HostState

type HostState struct {
	CheckBy                 string           `json:"check_by"`
	CheckAt                 time.Time        `json:"check_at"`
	PingOk                  bool             `json:"ping_ok"`
	PingStable              bool             `json:"ping_stable"`
	IP                      string           `json:"ip"`
	RunID                   string           `json:"runid"`
	IsMaster                bool             `json:"is_master"`
	IsOffline               bool             `json:"is_offline"`
	IsReadOnly              bool             `json:"is_read_only"`
	IsReplPaused            bool             `json:"is_repl_paused"`
	MasterReplicationOffset int64            `json:"master_replication_offset"`
	SecondReplicationOffset int64            `json:"second_replication_offset"`
	ReplicationBacklogStart int64            `json:"replication_backlog_start"`
	ReplicationBacklogSize  int64            `json:"replication_backlog_size"`
	ReplicationID           string           `json:"replication_id"`
	ReplicationID2          string           `json:"replication_id2"`
	Error                   string           `json:"error"`
	ConnectedReplicas       []string         `json:"connected_replicas"`
	ReplicaState            *ReplicaState    `json:"replica_state"`
	SentiCacheState         *SentiCacheState `json:"senticache_state"`
}

HostState contains status check performed by some rdsync process

func (*HostState) String

func (hs *HostState) String() string

type Maintenance

type Maintenance struct {
	InitiatedBy  string    `json:"initiated_by"`
	InitiatedAt  time.Time `json:"initiated_at"`
	RdSyncPaused bool      `json:"rdsync_paused"`
	ShouldLeave  bool      `json:"should_leave"`
}

Maintenance struct presence means that cluster under manual control

func (*Maintenance) String

func (m *Maintenance) String() string

type PoisonPill

type PoisonPill struct {
	Applied     bool      `json:"applied"`
	InitiatedAt time.Time `json:"initiated_at"`
	InitiatedBy string    `json:"initiated_by"`
	TargetHost  string    `json:"target_host"`
	Cause       string    `json:"cause"`
}

func (*PoisonPill) String

func (pp *PoisonPill) String() string

type ReplicaState

type ReplicaState struct {
	MasterHost           string `json:"master_host"`
	MasterLinkState      bool   `json:"master_link_state"`
	MasterLinkDownTime   int64  `json:"master_link_down_time"`
	MasterSyncInProgress bool   `json:"master_sync_in_progress"`
	ReplicationOffset    int64  `json:"replication_offset"`
}

ReplicaState contains replica specific info. Master always has this state empty

func (*ReplicaState) String

func (rs *ReplicaState) String() string

type SentiCacheState

type SentiCacheState struct {
	Name  string `json:"name"`
	RunID string `json:"runid"`
}

SentiCacheState contains senticache specific info. Cluster-mode nodes has this state empty

func (*SentiCacheState) String

func (ss *SentiCacheState) String() string

type Switchover

type Switchover struct {
	From        string              `json:"from"`
	To          string              `json:"to"`
	Cause       string              `json:"cause"`
	InitiatedBy string              `json:"initiated_by"`
	InitiatedAt time.Time           `json:"initiated_at"`
	StartedBy   string              `json:"started_by"`
	StartedAt   time.Time           `json:"started_at"`
	Result      *SwitchoverResult   `json:"result"`
	Progress    *SwitchoverProgress `json:"progress"`
	RunCount    int                 `json:"run_count"`
}

Switchover contains info about currently running or scheduled switchover/failover process

func (*Switchover) String

func (sw *Switchover) String() string

type SwitchoverProgress

type SwitchoverProgress struct {
	Version    int    `json:"version"`
	Phase      int    `json:"phase"`
	NewMaster  string `json:"new_master"`
	MostRecent string `json:"most_recent"`
}

SwitchoverProgress contains intents and status of running switchover

type SwitchoverResult

type SwitchoverResult struct {
	Ok         bool      `json:"ok"`
	Error      string    `json:"error"`
	FinishedAt time.Time `json:"finished_at"`
}

SwitchoverResult contains results of finished/failed switchover

Jump to

Keyboard shortcuts

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