dcs

package
v0.7.1-beta.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: AGPL-3.0 Imports: 20 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
	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) GetMemberAddrWithName

func (c *Cluster) GetMemberAddrWithName(name string) 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) HasMember

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

func (*Cluster) IsLocked

func (c *Cluster) IsLocked() bool

type DBState

type DBState struct {
	OpTimestamp int64
	Extra       map[string]string
}

type DCS

type DCS interface {
	Initialize(*Cluster) error

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

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

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

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

	// cluster scope leader lock
	AttempAcquireLease() error
	CreateLease() error
	IsLeaseExist() (bool, error)
	HasLease() bool
	ReleaseLease() error
	UpdateLease() error

	GetLeader() (*Leader, error)
}

func GetStore

func GetStore() DCS

type HaConfig

type HaConfig struct {
	DeleteMembers map[string]MemberToDelete
	// contains filtered or unexported fields
}

func (*HaConfig) AddMemberToDelete

func (c *HaConfig) AddMemberToDelete(member *Member)

func (*HaConfig) FinishDeleted

func (c *HaConfig) FinishDeleted(member *Member)

func (*HaConfig) GetMaxLagOnSwitchover

func (c *HaConfig) GetMaxLagOnSwitchover() int64

func (*HaConfig) GetMemberToDelete

func (c *HaConfig) GetMemberToDelete(member *Member) *MemberToDelete

func (*HaConfig) GetTTL

func (c *HaConfig) GetTTL() int

func (*HaConfig) IsDeleted

func (c *HaConfig) IsDeleted(member *Member) bool

func (*HaConfig) IsDeleting

func (c *HaConfig) IsDeleting(member *Member) bool

func (*HaConfig) IsEnable

func (c *HaConfig) IsEnable() bool

type KubernetesStore

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

func NewKubernetesStore

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

func (*KubernetesStore) AddCurrentMember

func (store *KubernetesStore) AddCurrentMember() error

func (*KubernetesStore) AttempAcquireLease

func (store *KubernetesStore) AttempAcquireLease() error

func (*KubernetesStore) CreateHaConfig

func (store *KubernetesStore) CreateHaConfig(cluster *Cluster) error

func (*KubernetesStore) CreateLease

func (store *KubernetesStore) CreateLease() error

func (*KubernetesStore) CreateSwitchover

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

func (*KubernetesStore) DeleteCluser

func (store *KubernetesStore) DeleteCluser()

func (*KubernetesStore) DeleteLeader

func (store *KubernetesStore) DeleteLeader() error

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) HasLease

func (store *KubernetesStore) HasLease() bool

func (*KubernetesStore) Initialize

func (store *KubernetesStore) Initialize(cluster *Cluster) error

func (*KubernetesStore) IsLeaseExist

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

func (*KubernetesStore) ReleaseLease

func (store *KubernetesStore) ReleaseLease() error

func (*KubernetesStore) ResetCluser

func (store *KubernetesStore) ResetCluser()

func (*KubernetesStore) UpdateHaConfig

func (store *KubernetesStore) UpdateHaConfig() error

func (*KubernetesStore) UpdateLease

func (store *KubernetesStore) UpdateLease() error

type Leader

type Leader struct {
	DBState     *DBState
	Index       string
	Name        string
	AcquireTime int64
	RenewTime   int64
	TTL         int
	Resource    any
}

type Member

type Member struct {
	Index          string
	Name           string
	Role           string
	PodIP          string
	DBPort         string
	SQLChannelPort string
	UID            string
	// contains filtered or unexported fields
}

func (*Member) GetName

func (m *Member) GetName() string

type MemberToDelete

type MemberToDelete struct {
	UID        string
	IsFinished bool
}

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