bcs

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType int
const (
	ActionTypeMakeNobody ActionType = iota
	ActionTypeMakeLeader
	ActionTypeMakeSlave
)

type LeaderCallbacks

type LeaderCallbacks struct {
	OnStartedLeading func(stop <-chan struct{})
	OnStoppedLeading func()
}

LeaderCallbacks if the callback functions for LeaderElector

type LeaderElector

type LeaderElector struct {
	StopChan chan struct{}
	// contains filtered or unexported fields
}

LeaderElector takes a NodeRegister and consumes its ServerEvents

func NewLeaderElector

func NewLeaderElector(nreg *register.NodeRegister, callbacks *LeaderCallbacks) *LeaderElector

func (*LeaderElector) IsLeader

func (le *LeaderElector) IsLeader() bool

func (*LeaderElector) Run

func (le *LeaderElector) Run()

Run starts a loop reads events from nreg.StateChan, when any ServiceEvent causes current role to be changed, it will use goroutine to run callback functions

func (*LeaderElector) SetRole

func (le *LeaderElector) SetRole(role Role)

type LeaderState

type LeaderState struct{}

State transition for Leader State

func (LeaderState) OnMakeLeader

func (s LeaderState) OnMakeLeader(elector *LeaderElector)

func (LeaderState) OnMakeNobody

func (s LeaderState) OnMakeNobody(elector *LeaderElector)

func (LeaderState) OnMakeSlave

func (s LeaderState) OnMakeSlave(elector *LeaderElector)

type NobodyState

type NobodyState struct{}

State transition for Nobody State

func (NobodyState) OnMakeLeader

func (s NobodyState) OnMakeLeader(elector *LeaderElector)

func (NobodyState) OnMakeNobody

func (s NobodyState) OnMakeNobody(elector *LeaderElector)

func (NobodyState) OnMakeSlave

func (s NobodyState) OnMakeSlave(elector *LeaderElector)

type Role

type Role int
const (
	RoleNobody Role = iota
	RoleLeader
	RoleSlave
)

type RoleState

type RoleState interface {
	OnMakeNobody(elector *LeaderElector)
	OnMakeLeader(elector *LeaderElector)
	OnMakeSlave(elector *LeaderElector)
}

func NewRoleState

func NewRoleState(role Role) RoleState

type ServiceNode

type ServiceNode struct {
	Id   string
	Info types.ServerInfo
}

ServiceNode is node info for bcs services.

func NewServiceNode

func NewServiceNode(info types.ServerInfo) ServiceNode

func (*ServiceNode) OwnsPayload

func (n *ServiceNode) OwnsPayload(payload []byte) bool

func (*ServiceNode) Payload

func (n *ServiceNode) Payload() []byte

func (*ServiceNode) PrimaryKey

func (n *ServiceNode) PrimaryKey() string

type SlaveState

type SlaveState struct{}

State transition for Slave State

func (SlaveState) OnMakeLeader

func (s SlaveState) OnMakeLeader(elector *LeaderElector)

func (SlaveState) OnMakeNobody

func (s SlaveState) OnMakeNobody(elector *LeaderElector)

func (SlaveState) OnMakeSlave

func (s SlaveState) OnMakeSlave(elector *LeaderElector)

Jump to

Keyboard shortcuts

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