dmapi

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func MasterClientURL

func MasterClientURL(namespace, clusterName, scheme string) string

MasterClientURL builds the url of master client

func MasterPeerClientURL

func MasterPeerClientURL(namespace, clusterName, podName, scheme string) string

MasterPeerClientURL builds the url of master peer client. It's used to evict leader because dm can't forward evict leader command now

Types

type Action

type Action struct {
	ID     uint64
	Name   string
	Labels map[string]string
}

type ActionType

type ActionType string
const (
	GetMastersActionType   ActionType = "GetMasters"
	GetWorkersActionType   ActionType = "GetWorkers"
	GetLeaderActionType    ActionType = "GetLeader"
	EvictLeaderActionType  ActionType = "EvictLeader"
	DeleteMasterActionType ActionType = "DeleteMaster"
	DeleteWorkerActionType ActionType = "DeleteWorker"
)

type FakeMasterClient

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

FakeMasterClient implements a fake version of MasterClient.

func NewFakeMasterClient

func NewFakeMasterClient() *FakeMasterClient

func (*FakeMasterClient) AddReaction

func (c *FakeMasterClient) AddReaction(actionType ActionType, reaction Reaction)

func (*FakeMasterClient) DeleteMaster

func (c *FakeMasterClient) DeleteMaster(_ string) error

func (*FakeMasterClient) DeleteWorker

func (c *FakeMasterClient) DeleteWorker(_ string) error

func (*FakeMasterClient) EvictLeader

func (c *FakeMasterClient) EvictLeader() error

func (*FakeMasterClient) GetLeader

func (c *FakeMasterClient) GetLeader() (MembersLeader, error)

func (*FakeMasterClient) GetMasters

func (c *FakeMasterClient) GetMasters() ([]*MastersInfo, error)

func (*FakeMasterClient) GetWorkers

func (c *FakeMasterClient) GetWorkers() ([]*WorkersInfo, error)

type FakeMasterControl

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

FakeMasterControl implements a fake version of MasterControlInterface.

func NewFakeMasterControl

func NewFakeMasterControl(secretLister corelisterv1.SecretLister) *FakeMasterControl

func (*FakeMasterControl) GetMasterClient

func (fmc *FakeMasterControl) GetMasterClient(namespace string, dcName string, tlsEnabled bool) MasterClient

func (*FakeMasterControl) GetMasterPeerClient

func (fmc *FakeMasterControl) GetMasterPeerClient(namespace, dcName, podName string, tlsEnabled bool) MasterClient

func (*FakeMasterControl) SetMasterClient

func (fmc *FakeMasterControl) SetMasterClient(namespace, dcName string, masterClient MasterClient)

func (*FakeMasterControl) SetMasterPeerClient

func (fmc *FakeMasterControl) SetMasterPeerClient(namespace, dcName, podName string, masterPeerClient MasterClient)

type LeaderResp

type LeaderResp struct {
	RespHeader     `json:",inline"`
	ListMemberResp []*ListMemberLeader `json:"members,omitempty"`
}

type ListMemberLeader

type ListMemberLeader struct {
	MembersLeader `json:"leader,omitempty"`
}

type ListMemberMaster

type ListMemberMaster struct {
	MembersMaster `json:"master,omitempty"`
}

type ListMemberWorker

type ListMemberWorker struct {
	MembersWorker `json:"worker,omitempty"`
}

type MasterClient

type MasterClient interface {
	// GetMasters returns all master members from cluster
	GetMasters() ([]*MastersInfo, error)
	GetWorkers() ([]*WorkersInfo, error)
	GetLeader() (MembersLeader, error)
	EvictLeader() error
	DeleteMaster(name string) error
	DeleteWorker(name string) error
}

MasterClient provides master server's api

func NewMasterClient

func NewMasterClient(url string, timeout time.Duration, tlsConfig *tls.Config, disableKeepalive bool) MasterClient

NewMasterClient returns a new MasterClient

type MasterControlInterface

type MasterControlInterface interface {
	// GetMasterClient provides MasterClient of the dm cluster.
	GetMasterClient(namespace string, dcName string, tlsEnabled bool) MasterClient
	GetMasterPeerClient(namespace string, dcName, podName string, tlsEnabled bool) MasterClient
}

MasterControlInterface is an interface that knows how to manage and get dm cluster's master client

func NewDefaultMasterControl

func NewDefaultMasterControl(secretLister corelisterv1.SecretLister) MasterControlInterface

NewDefaultMasterControl returns a defaultMasterControl instance

type MastersInfo

type MastersInfo struct {
	Name       string   `json:"name,omitempty"`
	MemberID   string   `json:"memberID,omitempty"`
	Alive      bool     `json:"alive,omitempty"`
	PeerURLs   []string `json:"peerURLs,omitempty"`
	ClientURLs []string `json:"clientURLs,omitempty"`
}

type MastersResp

type MastersResp struct {
	RespHeader     `json:",inline"`
	ListMemberResp []*ListMemberMaster `json:"members,omitempty"`
}

type MembersLeader

type MembersLeader struct {
	Msg  string `json:"msg,omitempty"`
	Name string `json:"name,omitempty"`
	Addr string `json:"addr,omitempty"`
}

type MembersMaster

type MembersMaster struct {
	Msg     string         `json:"msg,omitempty"`
	Masters []*MastersInfo `json:"masters,omitempty"`
}

type MembersWorker

type MembersWorker struct {
	Msg     string         `json:"msg,omitempty"`
	Workers []*WorkersInfo `json:"workers,omitempty"`
}

type NotFoundReaction

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

func (*NotFoundReaction) Error

func (nfr *NotFoundReaction) Error() string

type Reaction

type Reaction func(action *Action) (interface{}, error)

type RespHeader

type RespHeader struct {
	Result bool   `json:"result,omitempty"`
	Msg    string `json:"msg,omitempty"`
}

type WorkerResp

type WorkerResp struct {
	RespHeader     `json:",inline"`
	ListMemberResp []*ListMemberWorker `json:"members,omitempty"`
}

type WorkersInfo

type WorkersInfo struct {
	Name   string `json:"name,omitempty"`
	Addr   string `json:"addr,omitempty"`
	Stage  string `json:"stage,omitempty"`
	Source string `json:"source,omitempty"`
}

Jump to

Keyboard shortcuts

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