dcs

package
v0.8.0-beta.37 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: AGPL-3.0 Imports: 23 Imported by: 1

Documentation

Overview

Package dcs is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitStore

func InitStore() error

func SetStore

func SetStore(d DCS)

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

func (c *Cluster) GetMemberShortAddr(member Member) 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() error

	// cluster manage functions
	GetClusterName() string
	GetCluster() (*Cluster, error)
	GetClusterFromCache() *Cluster
	ResetCluster()
	DeleteCluster()

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

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

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

	// cluster scope leader lock
	AttemptAcquireLease() 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

func (*HaConfig) SetEnable

func (c *HaConfig) SetEnable(enable bool)

type KubernetesStore

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

func NewKubernetesStore

func NewKubernetesStore() (*KubernetesStore, error)

func (*KubernetesStore) AddCurrentMember

func (store *KubernetesStore) AddCurrentMember() error

func (*KubernetesStore) AttemptAcquireLease

func (store *KubernetesStore) AttemptAcquireLease() error

func (*KubernetesStore) CreateHaConfig

func (store *KubernetesStore) CreateHaConfig() error

func (*KubernetesStore) CreateLease

func (store *KubernetesStore) CreateLease() error

func (*KubernetesStore) CreateSwitchover

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

func (*KubernetesStore) DeleteCluster

func (store *KubernetesStore) DeleteCluster()

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() error

func (*KubernetesStore) IsLeaseExist

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

func (*KubernetesStore) ReleaseLease

func (store *KubernetesStore) ReleaseLease() error

func (*KubernetesStore) ResetCluster

func (store *KubernetesStore) ResetCluster()

func (*KubernetesStore) SetCompName

func (store *KubernetesStore) SetCompName(componentName string)

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
	LorryPort 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 MockDCS

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

MockDCS is a mock of DCS interface.

func NewMockDCS

func NewMockDCS(ctrl *gomock.Controller) *MockDCS

NewMockDCS creates a new mock instance.

func (*MockDCS) AddCurrentMember

func (m *MockDCS) AddCurrentMember() error

AddCurrentMember mocks base method.

func (*MockDCS) AttemptAcquireLease

func (m *MockDCS) AttemptAcquireLease() error

AttemptAcquireLease mocks base method.

func (*MockDCS) CreateLease

func (m *MockDCS) CreateLease() error

CreateLease mocks base method.

func (*MockDCS) CreateSwitchover

func (m *MockDCS) CreateSwitchover(arg0, arg1 string) error

CreateSwitchover mocks base method.

func (*MockDCS) DeleteCluster

func (m *MockDCS) DeleteCluster()

DeleteCluster mocks base method.

func (*MockDCS) DeleteSwitchover

func (m *MockDCS) DeleteSwitchover() error

DeleteSwitchover mocks base method.

func (*MockDCS) EXPECT

func (m *MockDCS) EXPECT() *MockDCSMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDCS) GetCluster

func (m *MockDCS) GetCluster() (*Cluster, error)

GetCluster mocks base method.

func (*MockDCS) GetClusterFromCache

func (m *MockDCS) GetClusterFromCache() *Cluster

GetClusterFromCache mocks base method.

func (*MockDCS) GetClusterName

func (m *MockDCS) GetClusterName() string

GetClusterName mocks base method.

func (*MockDCS) GetHaConfig

func (m *MockDCS) GetHaConfig() (*HaConfig, error)

GetHaConfig mocks base method.

func (*MockDCS) GetLeader

func (m *MockDCS) GetLeader() (*Leader, error)

GetLeader mocks base method.

func (*MockDCS) GetMembers

func (m *MockDCS) GetMembers() ([]Member, error)

GetMembers mocks base method.

func (*MockDCS) GetSwitchover

func (m *MockDCS) GetSwitchover() (*Switchover, error)

GetSwitchover mocks base method.

func (*MockDCS) HasLease

func (m *MockDCS) HasLease() bool

HasLease mocks base method.

func (*MockDCS) Initialize

func (m *MockDCS) Initialize() error

Initialize mocks base method.

func (*MockDCS) IsLeaseExist

func (m *MockDCS) IsLeaseExist() (bool, error)

IsLeaseExist mocks base method.

func (*MockDCS) ReleaseLease

func (m *MockDCS) ReleaseLease() error

ReleaseLease mocks base method.

func (*MockDCS) ResetCluster

func (m *MockDCS) ResetCluster()

ResetCluster mocks base method.

func (*MockDCS) UpdateHaConfig

func (m *MockDCS) UpdateHaConfig() error

UpdateHaConfig mocks base method.

func (*MockDCS) UpdateLease

func (m *MockDCS) UpdateLease() error

UpdateLease mocks base method.

type MockDCSMockRecorder

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

MockDCSMockRecorder is the mock recorder for MockDCS.

func (*MockDCSMockRecorder) AddCurrentMember

func (mr *MockDCSMockRecorder) AddCurrentMember() *gomock.Call

AddCurrentMember indicates an expected call of AddCurrentMember.

func (*MockDCSMockRecorder) AttemptAcquireLease

func (mr *MockDCSMockRecorder) AttemptAcquireLease() *gomock.Call

AttemptAcquireLease indicates an expected call of AttemptAcquireLease.

func (*MockDCSMockRecorder) CreateLease

func (mr *MockDCSMockRecorder) CreateLease() *gomock.Call

CreateLease indicates an expected call of CreateLease.

func (*MockDCSMockRecorder) CreateSwitchover

func (mr *MockDCSMockRecorder) CreateSwitchover(arg0, arg1 interface{}) *gomock.Call

CreateSwitchover indicates an expected call of CreateSwitchover.

func (*MockDCSMockRecorder) DeleteCluster

func (mr *MockDCSMockRecorder) DeleteCluster() *gomock.Call

DeleteCluster indicates an expected call of DeleteCluster.

func (*MockDCSMockRecorder) DeleteSwitchover

func (mr *MockDCSMockRecorder) DeleteSwitchover() *gomock.Call

DeleteSwitchover indicates an expected call of DeleteSwitchover.

func (*MockDCSMockRecorder) GetCluster

func (mr *MockDCSMockRecorder) GetCluster() *gomock.Call

GetCluster indicates an expected call of GetCluster.

func (*MockDCSMockRecorder) GetClusterFromCache

func (mr *MockDCSMockRecorder) GetClusterFromCache() *gomock.Call

GetClusterFromCache indicates an expected call of GetClusterFromCache.

func (*MockDCSMockRecorder) GetClusterName

func (mr *MockDCSMockRecorder) GetClusterName() *gomock.Call

GetClusterName indicates an expected call of GetClusterName.

func (*MockDCSMockRecorder) GetHaConfig

func (mr *MockDCSMockRecorder) GetHaConfig() *gomock.Call

GetHaConfig indicates an expected call of GetHaConfig.

func (*MockDCSMockRecorder) GetLeader

func (mr *MockDCSMockRecorder) GetLeader() *gomock.Call

GetLeader indicates an expected call of GetLeader.

func (*MockDCSMockRecorder) GetMembers

func (mr *MockDCSMockRecorder) GetMembers() *gomock.Call

GetMembers indicates an expected call of GetMembers.

func (*MockDCSMockRecorder) GetSwitchover

func (mr *MockDCSMockRecorder) GetSwitchover() *gomock.Call

GetSwitchover indicates an expected call of GetSwitchover.

func (*MockDCSMockRecorder) HasLease

func (mr *MockDCSMockRecorder) HasLease() *gomock.Call

HasLease indicates an expected call of HasLease.

func (*MockDCSMockRecorder) Initialize

func (mr *MockDCSMockRecorder) Initialize() *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockDCSMockRecorder) IsLeaseExist

func (mr *MockDCSMockRecorder) IsLeaseExist() *gomock.Call

IsLeaseExist indicates an expected call of IsLeaseExist.

func (*MockDCSMockRecorder) ReleaseLease

func (mr *MockDCSMockRecorder) ReleaseLease() *gomock.Call

ReleaseLease indicates an expected call of ReleaseLease.

func (*MockDCSMockRecorder) ResetCluster

func (mr *MockDCSMockRecorder) ResetCluster() *gomock.Call

ResetCluster indicates an expected call of ResetCluster.

func (*MockDCSMockRecorder) UpdateHaConfig

func (mr *MockDCSMockRecorder) UpdateHaConfig() *gomock.Call

UpdateHaConfig indicates an expected call of UpdateHaConfig.

func (*MockDCSMockRecorder) UpdateLease

func (mr *MockDCSMockRecorder) UpdateLease() *gomock.Call

UpdateLease indicates an expected call of UpdateLease.

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