serverstate

package
v1.1.0-beta.0...-97e7b5c Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StateUpgrading represents the cluster global state is upgrading. It is exports for testing.
	StateUpgrading = "upgrading"
	// StateNormalRunning represents the cluster global state is normal running. It is exports for testing.
	StateNormalRunning = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type StateInfo

type StateInfo struct {
	State string `json:"state"`
}

StateInfo is the tidb cluster state. It will not be updated when the tidb cluster upgrading.

func NewStateInfo

func NewStateInfo(state string) *StateInfo

NewStateInfo is new a StateInfo.

func (*StateInfo) Marshal

func (info *StateInfo) Marshal() ([]byte, error)

Marshal `StateInfo` into bytes.

func (*StateInfo) Unmarshal

func (info *StateInfo) Unmarshal(v []byte) error

Unmarshal `StateInfo` from bytes.

type Syncer

type Syncer interface {
	// Init sets the global schema version path to etcd if it isn't exist,
	// then watch this path, and initializes the self schema version to etcd.
	Init(ctx context.Context) error
	// UpdateGlobalState updates the latest version to the global path on etcd until updating is successful or the ctx is done.
	UpdateGlobalState(ctx context.Context, stateInfo *StateInfo) error
	// GetGlobalState gets the global state from etcd.
	GetGlobalState(ctx context.Context) (*StateInfo, error)
	// IsUpgradingState returns whether the cluster state is upgrading.
	IsUpgradingState() bool
	WatchChan() clientv3.WatchChan
	Rewatch(ctx context.Context)
}

Syncer is used to synchronize server state. currently there are only 2 states: running/upgrading, and is only used for the 'smooth upgrade' feature.

func NewEtcdSyncer

func NewEtcdSyncer(etcdCli *clientv3.Client, etcdPath string) Syncer

NewEtcdSyncer creates a new Syncer.

func NewMemSyncer

func NewMemSyncer() Syncer

NewMemSyncer creates a new memSyncer.

Jump to

Keyboard shortcuts

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