dcs

package
v0.6.0-beta.33 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ClusterCompName string
	Namespace       string
	Replicas        int32
	HaConfig        *HaConfig
	Leader          *Leader
	OpTime          int64
	Members         []Member
	Switchover      *Switchover
	Extra           map[string]string
	// contains filtered or unexported fields
}

func (*Cluster) GetLeaderMember

func (c *Cluster) GetLeaderMember() *Member

func (*Cluster) GetMemberAddr

func (c *Cluster) GetMemberAddr(member Member) string

func (*Cluster) GetMemberAddrWithPort

func (c *Cluster) GetMemberAddrWithPort(member Member) string

func (*Cluster) GetMemberAddrs

func (c *Cluster) GetMemberAddrs() []string

func (*Cluster) GetMemberName

func (c *Cluster) GetMemberName() []string

func (*Cluster) GetMemberWithHost

func (c *Cluster) GetMemberWithHost(host string) *Member

func (*Cluster) GetMemberWithName

func (c *Cluster) GetMemberWithName(name string) *Member

func (*Cluster) GetOpTime

func (c *Cluster) GetOpTime() int64

func (*Cluster) HasMember

func (c *Cluster) HasMember(memberName string) bool

func (*Cluster) IsLocked

func (c *Cluster) IsLocked() bool

type DCS

type DCS interface {
	Initialize() error

	// cluster manage functions
	GetClusterName() string
	GetCluster() (*Cluster, error)
	ResetCluser()
	DeleteCluser()

	// cluster scole ha config
	GetHaConfig() (*HaConfig, error)

	// member manager funtions
	GetMembers() ([]Member, error)
	AddCurrentMember() error

	// manual switchover
	GetSwitchover() (*Switchover, error)
	CreateSwitchover(string, string) error
	DeleteSwitchover() error

	// cluster scope leader lock
	AttempAcquireLock() error
	CreateLock() error
	IsLockExist() (bool, error)
	HasLock() bool
	ReleaseLock() error
	UpdateLock() error

	GetLeader() (*Leader, error)
}

func GetStore

func GetStore() DCS

type HaConfig

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

func (*HaConfig) GetMaxLagOnSwitchover

func (c *HaConfig) GetMaxLagOnSwitchover() int64

func (*HaConfig) GetTTL

func (c *HaConfig) GetTTL() int

type KubernetesStore

type KubernetesStore struct {
	LeaderObservedTime int64
	// contains filtered or unexported fields
}

func NewKubernetesStore

func NewKubernetesStore(logger logger.Logger) (*KubernetesStore, error)

func (*KubernetesStore) AddCurrentMember

func (store *KubernetesStore) AddCurrentMember() error

func (*KubernetesStore) AttempAcquireLock

func (store *KubernetesStore) AttempAcquireLock() error

func (*KubernetesStore) CreateLock

func (store *KubernetesStore) CreateLock() error

func (*KubernetesStore) CreateSwitchover

func (store *KubernetesStore) CreateSwitchover(leader, candidate string) error

func (*KubernetesStore) DeleteCluser

func (store *KubernetesStore) DeleteCluser()

func (*KubernetesStore) DeleteSwitchover

func (store *KubernetesStore) DeleteSwitchover() error

func (*KubernetesStore) GetCluster

func (store *KubernetesStore) GetCluster() (*Cluster, error)

func (*KubernetesStore) GetClusterFromCache

func (store *KubernetesStore) GetClusterFromCache() *Cluster

func (*KubernetesStore) GetClusterName

func (store *KubernetesStore) GetClusterName() string

func (*KubernetesStore) GetHaConfig

func (store *KubernetesStore) GetHaConfig() (*HaConfig, error)

func (*KubernetesStore) GetLeader

func (store *KubernetesStore) GetLeader() (*Leader, error)

func (*KubernetesStore) GetLeaderConfigMap

func (store *KubernetesStore) GetLeaderConfigMap() (*corev1.ConfigMap, error)

func (*KubernetesStore) GetMembers

func (store *KubernetesStore) GetMembers() ([]Member, error)

func (*KubernetesStore) GetSwitchOverConfigMap

func (store *KubernetesStore) GetSwitchOverConfigMap() (*corev1.ConfigMap, error)

func (*KubernetesStore) GetSwitchover

func (store *KubernetesStore) GetSwitchover() (*Switchover, error)

func (*KubernetesStore) HasLock

func (store *KubernetesStore) HasLock() bool

func (*KubernetesStore) Initialize

func (store *KubernetesStore) Initialize() error

func (*KubernetesStore) IsLockExist

func (store *KubernetesStore) IsLockExist() (bool, error)

func (*KubernetesStore) ReleaseLock

func (store *KubernetesStore) ReleaseLock() error

func (*KubernetesStore) ResetCluser

func (store *KubernetesStore) ResetCluser()

func (*KubernetesStore) UpdateLock

func (store *KubernetesStore) UpdateLock() error

type Leader

type Leader struct {
	Index       string
	Name        string
	AcquireTime int64
	RenewTime   int64
	TTL         int
	Resource    interface{}
}

type Member

type Member struct {
	Index          string
	Name           string
	Role           string
	PodIP          string
	DBPort         string
	SQLChannelPort string
}

func (*Member) GetName

func (m *Member) GetName() string

type Switchover

type Switchover struct {
	Index       string
	Leader      string
	Candidate   string
	ScheduledAt int64
}

func (*Switchover) GetCandidate

func (s *Switchover) GetCandidate() string

func (*Switchover) GetLeader

func (s *Switchover) GetLeader() string

Jump to

Keyboard shortcuts

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