api

package
v0.0.0-...-13d8ce4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrNoLeader returns for no leader in raft cluster
	ErrNoLeader = errors.New("kingbus: no leader")
	//ErrNotLeader returns for the node is not leader
	ErrNotLeader = errors.New("kingbus: node is not leader")
)

Functions

This section is empty.

Types

type AdminServer

type AdminServer struct {
	AdminAddr string
	// contains filtered or unexported fields
}

AdminServer is a server for handling api call

func NewAdminServer

func NewAdminServer(addr string, svr Server, cluster Cluster) *AdminServer

NewAdminServer creates a admin server

func (*AdminServer) RegisterMiddleware

func (s *AdminServer) RegisterMiddleware()

RegisterMiddleware implements register middleware in web

func (*AdminServer) RegisterURL

func (s *AdminServer) RegisterURL()

RegisterURL implements url binding

func (*AdminServer) Run

func (s *AdminServer) Run()

Run a AdminServer

func (*AdminServer) Stop

func (s *AdminServer) Stop()

Stop AdminServer

type BinlogServerHandler

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

BinlogServerHandler is used for the api call of handling binlog server handler with lock will keep calling api with no compete

func (*BinlogServerHandler) GetBinlogServerStatus

func (h *BinlogServerHandler) GetBinlogServerStatus(echoCtx echo.Context) error

GetBinlogServerStatus implements get binlog server status in the runtime state

func (*BinlogServerHandler) StartBinlogServer

func (h *BinlogServerHandler) StartBinlogServer(echoCtx echo.Context) error

StartBinlogServer implements start a binlog server

func (*BinlogServerHandler) StopBinlogServer

func (h *BinlogServerHandler) StopBinlogServer(echoCtx echo.Context) error

StopBinlogServer implements stop binlog server

type BinlogSyncerHandler

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

BinlogSyncerHandler is used handling the api call of binlog syncer. handler with lock will keep calling api with no compete

func (*BinlogSyncerHandler) GetBinlogSyncerStatus

func (h *BinlogSyncerHandler) GetBinlogSyncerStatus(echoCtx echo.Context) error

GetBinlogSyncerStatus implements get binlog syncer status in the runtime state

func (*BinlogSyncerHandler) ProposeSyncerArgs

func (h *BinlogSyncerHandler) ProposeSyncerArgs(args *config.SyncerArgs) error

ProposeSyncerArgs implements propose start syncer args to raft cluster when other node became to lead, it can use this information start syncer automatically

func (*BinlogSyncerHandler) StartBinlogSyncer

func (h *BinlogSyncerHandler) StartBinlogSyncer(echoCtx echo.Context) error

StartBinlogSyncer implements start a binlog syncer

func (*BinlogSyncerHandler) StopBinlogSyncer

func (h *BinlogSyncerHandler) StopBinlogSyncer(echoCtx echo.Context) error

StopBinlogSyncer implements stop binlog syncer

type Cluster

type Cluster interface {
	// GetID returns the cluster id
	GetID() types.ID
	// Members returns a slice of members sorted by their id
	Members() []*membership.Member
	// Member retrieves a particular member based on id, or nil if the
	// member does not exist in the cluster
	Member(id types.ID) *membership.Member

	MemberByName(name string) *membership.Member
}

Cluster is responsible for a collection of members in one etcd cluster.

type MembershipHandler

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

MembershipHandler is used for handling the api call of membership in raft cluster

func (*MembershipHandler) AddMember

func (h *MembershipHandler) AddMember(echoCtx echo.Context) error

AddMember implements add a member into raft cluster

func (*MembershipHandler) DeleteMember

func (h *MembershipHandler) DeleteMember(echoCtx echo.Context) error

DeleteMember implements remove a member from raft cluster

func (*MembershipHandler) GetCluster

func (h *MembershipHandler) GetCluster(echoCtx echo.Context) error

GetCluster implements get information of raft cluster

func (*MembershipHandler) GetMembers

func (h *MembershipHandler) GetMembers(echoCtx echo.Context) error

GetMembers implements get information of membership, not include lead information

func (*MembershipHandler) UpdateAdminURL

func (h *MembershipHandler) UpdateAdminURL(echoCtx echo.Context) error

UpdateAdminURL implements update raft node admin url in raft cluster

func (*MembershipHandler) UpdateMember

func (h *MembershipHandler) UpdateMember(echoCtx echo.Context) error

UpdateMember implements update member information

type Role

type Role struct {
	ID string `json:"Id"`
	membership.RaftAttributes
	membership.Attributes
	IsLeader bool `json:"isLeader"`
}

Role represents a node in cluster

type Server

type Server interface {
	// AddMember attempts to add a member into the cluster. It will return
	// ErrIDRemoved if member id is removed from the cluster, or return
	// ErrIDExists if member id exists in the cluster.
	AddMember(ctx context.Context, memb membership.Member) ([]*membership.Member, error)
	// RemoveMember attempts to remove a member from the cluster. It will
	// return ErrIDRemoved if member id is removed from the cluster, or return
	// ErrIDNotFound if member id is not in the cluster.
	RemoveMember(ctx context.Context, id uint64) ([]*membership.Member, error)
	// UpdateMember attempts to update an existing member in the cluster. It will
	// return ErrIDNotFound if the member id does not exist.
	UpdateMember(ctx context.Context, updateMemb membership.Member) ([]*membership.Member, error)
	GetIP() string
	IsLeader() bool
	Leader() types.ID

	Propose(data []byte) error
	StartServer(svrType config.SubServerType, args interface{}) error
	StopServer(svrType config.SubServerType)
	GetServerStatus(svrType config.SubServerType) interface{}
}

Server is a kingbus server interface

Jump to

Keyboard shortcuts

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