Documentation ¶
Index ¶
- Constants
- type ConsistentDecoder
- type MessageStation
- type NoopConsistentBroadcaster
- func (b *NoopConsistentBroadcaster) ID() string
- func (b *NoopConsistentBroadcaster) IsRunning() bool
- func (b *NoopConsistentBroadcaster) NoopBroadcast(local consistent_service.Node, remote consistent_service.Node) (interface{}, error)
- func (b *NoopConsistentBroadcaster) PreBroadcaster() consistent_service.Broadcast
- func (b *NoopConsistentBroadcaster) Start() error
- func (b *NoopConsistentBroadcaster) Stop() error
- func (b *NoopConsistentBroadcaster) TimePattern() interface{}
- type RaftHeartbeatBroadcaster
- type RaftLinkBroadcaster
- type RaftNode
- type RaftNodeHeartBeat
- type RaftNodeLink
- type RaftNodeStatus
- type StatusConsistentStub
- func (c *StatusConsistentStub) AddNode(nodeIDs ...string) error
- func (c *StatusConsistentStub) DeleteNode(nodeIDs ...string) error
- func (c *StatusConsistentStub) GetNodesWithActiveState() []consensuspb.ConsensusNodeInfo
- func (c *StatusConsistentStub) IsRunning() bool
- func (c *StatusConsistentStub) ResetNodes(nodes []string)
- func (c *StatusConsistentStub) Start() error
- func (c *StatusConsistentStub) Stop() error
Constants ¶
const ( // HeartBeat represents heartbeat type status HeartBeat = iota + 1 // NodeLink represents node-linked type status NodeLink )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsistentDecoder ¶ added in v3.0.1
type ConsistentDecoder struct {
// contains filtered or unexported fields
}
ConsistentDecoder used to parse different data
func NewConsistentDecoder ¶ added in v3.0.1
func NewConsistentDecoder(log protocol.Logger) *ConsistentDecoder
NewConsistentDecoder create a new ConsistentDecoder
func (*ConsistentDecoder) Decode ¶ added in v3.0.1
func (d *ConsistentDecoder) Decode(in interface{}) interface{}
Decode parse the message receive into a node data
func (*ConsistentDecoder) MsgType ¶ added in v3.0.1
func (d *ConsistentDecoder) MsgType() int8
MsgType the Message Types ConsistentDecoder supports
type MessageStation ¶
type MessageStation struct {
// contains filtered or unexported fields
}
MessageStation is a station for message dock Rely on msgbus to send and receive messages
func NewMessageStation ¶
func NewMessageStation(bus msgbus.MessageBus, log protocol.Logger) *MessageStation
NewMessageStation create a MessageStation instance register self to msgbus
func (*MessageStation) Close ¶
func (s *MessageStation) Close()
Close close the message station to prevent sending and receiving message
func (*MessageStation) OnMessage ¶
func (s *MessageStation) OnMessage(m *msgbus.Message)
OnMessage msgbus Subscriber interface implementation for receiving messages
func (*MessageStation) OnQuit ¶
func (s *MessageStation) OnQuit()
OnQuit msgbus Subscriber interface implementation for notifying subscribers that msgbus has been closed
func (*MessageStation) Receive ¶
func (s *MessageStation) Receive() interface{}
Receive message station receives message from msgbus and cache them which can be retrieved from station later
func (*MessageStation) Send ¶
func (s *MessageStation) Send(payload interface{})
Send put a message into station, then the message station will transport it by msgbus
func (*MessageStation) Start ¶ added in v3.0.1
func (s *MessageStation) Start() error
Start implements Start function for interface Message
func (*MessageStation) Stop ¶ added in v3.0.1
func (s *MessageStation) Stop() error
Stop implements Stop function for interface Message
type NoopConsistentBroadcaster ¶
type NoopConsistentBroadcaster struct {
// contains filtered or unexported fields
}
NoopConsistentBroadcaster is a broadcaster who does not implement any behavior you can't use it in production, but you can create a new broadcaster that inherits from it and just override the PreBroadcaster function.
func NewNoopConsistentBroadcaster ¶
func NewNoopConsistentBroadcaster(id string, interval time.Duration, log protocol.Logger) *NoopConsistentBroadcaster
NewNoopConsistentBroadcaster create a NoopConsistentBroadcaster instance id is the ID assigned to new broadcaster interval is the time interval used to generate messages at regular intervals.
func (*NoopConsistentBroadcaster) ID ¶
func (b *NoopConsistentBroadcaster) ID() string
ID get the broadcaster id
func (*NoopConsistentBroadcaster) IsRunning ¶
func (b *NoopConsistentBroadcaster) IsRunning() bool
IsRunning get if the broadcaster is running
func (*NoopConsistentBroadcaster) NoopBroadcast ¶
func (b *NoopConsistentBroadcaster) NoopBroadcast( local consistent_service.Node, remote consistent_service.Node) (interface{}, error)
NoopBroadcast the behavior function of NoopConsistentBroadcaster to generate a message
func (*NoopConsistentBroadcaster) PreBroadcaster ¶
func (b *NoopConsistentBroadcaster) PreBroadcaster() consistent_service.Broadcast
PreBroadcaster get a behavior function that can generate a message
func (*NoopConsistentBroadcaster) Start ¶
func (b *NoopConsistentBroadcaster) Start() error
Start start the broadcaster
func (*NoopConsistentBroadcaster) Stop ¶
func (b *NoopConsistentBroadcaster) Stop() error
Stop stop the broadcaster
func (*NoopConsistentBroadcaster) TimePattern ¶
func (b *NoopConsistentBroadcaster) TimePattern() interface{}
TimePattern get time interval for regularly pulling data
type RaftHeartbeatBroadcaster ¶
type RaftHeartbeatBroadcaster struct {
*NoopConsistentBroadcaster
}
RaftHeartbeatBroadcaster raft heartbeat broadcaster that is used to generate heartbeat messages inherited from NoopConsistentBroadcaster
func NewRaftStatusBroadcaster ¶
func NewRaftStatusBroadcaster(interval time.Duration, log protocol.Logger) *RaftHeartbeatBroadcaster
NewRaftStatusBroadcaster create a RaftHeartbeatBroadcaster instance
func (*RaftHeartbeatBroadcaster) Broadcast ¶
func (b *RaftHeartbeatBroadcaster) Broadcast( local consistent_service.Node, remote consistent_service.Node) (interface{}, error)
Broadcast the behavior function of RaftHeartbeatBroadcaster to generate a heartbeat message
func (*RaftHeartbeatBroadcaster) PreBroadcaster ¶
func (b *RaftHeartbeatBroadcaster) PreBroadcaster() consistent_service.Broadcast
PreBroadcaster get the raft heartbeat behavior function
type RaftLinkBroadcaster ¶
type RaftLinkBroadcaster struct { *NoopConsistentBroadcaster // contains filtered or unexported fields }
RaftLinkBroadcaster raft node linked information broadcaster
func NewRaftLinkBroadcaster ¶
func NewRaftLinkBroadcaster( stub *StatusConsistentStub, interval time.Duration, log protocol.Logger) *RaftLinkBroadcaster
NewRaftLinkBroadcaster create a RaftLinkBroadcaster instance
func (*RaftLinkBroadcaster) Broadcast ¶
func (b *RaftLinkBroadcaster) Broadcast( local consistent_service.Node, remote consistent_service.Node) (interface{}, error)
Broadcast the behavior function of RaftLinkBroadcaster to generate a node link message
func (*RaftLinkBroadcaster) PreBroadcaster ¶
func (b *RaftLinkBroadcaster) PreBroadcaster() consistent_service.Broadcast
PreBroadcaster get the raft node link behavior function
type RaftNode ¶
RaftNode represents a raft state node
func NewRaftNode ¶
func NewRaftNode(id string, status ...RaftNodeStatus) *RaftNode
NewRaftNode create a new RaftNode with status id is the node identity status is the status data that needs to be initialized
func (*RaftNode) StatusByType ¶
func (n *RaftNode) StatusByType(tpy int8) RaftNodeStatus
StatusByType get the status of the specified type if not exist return nil
func (*RaftNode) Statuses ¶
func (n *RaftNode) Statuses() map[int8]consistent_service.Status
Statuses get all status of the node
func (*RaftNode) UpdateStatus ¶
func (n *RaftNode) UpdateStatus(status consistent_service.Status)
UpdateStatus update node's status
type RaftNodeHeartBeat ¶
type RaftNodeHeartBeat struct {
// contains filtered or unexported fields
}
RaftNodeHeartBeat a heart beat status
func (*RaftNodeHeartBeat) Data ¶
func (s *RaftNodeHeartBeat) Data() interface{}
Data the data contained in the heartbeat status
func (*RaftNodeHeartBeat) Type ¶
func (s *RaftNodeHeartBeat) Type() int8
Type the type of heart beat status
func (*RaftNodeHeartBeat) Update ¶
func (s *RaftNodeHeartBeat) Update(status consistent_service.Status)
Update update status data
type RaftNodeLink ¶
type RaftNodeLink struct {
// contains filtered or unexported fields
}
RaftNodeLink node linked status
func (*RaftNodeLink) Data ¶
func (s *RaftNodeLink) Data() interface{}
Data the data contained in the node link status
func (*RaftNodeLink) Update ¶
func (s *RaftNodeLink) Update(status consistent_service.Status)
Update update status data
type RaftNodeStatus ¶
type RaftNodeStatus = consistent_service.Status
RaftNodeStatus alias of consistent_service.Status
type StatusConsistentStub ¶
type StatusConsistentStub struct {
// contains filtered or unexported fields
}
StatusConsistentStub is a stub that interacts with the consistency engine selfID is the id of local node. nodes is the state information of all nodes includes local node, key is the id of node, value is a raft node contains various states inside.
func NewStatusConsistentStub ¶
func NewStatusConsistentStub(nodeID string, msgbus msgbus.MessageBus, log protocol.Logger, ) (*StatusConsistentStub, error)
NewStatusConsistentStub create a StatusConsistentStub instance create a raft node with local node id and put it into nodes create a MessageStation for transporting message create a Broadcaster for generating message create a Decoder for decode message
func (*StatusConsistentStub) AddNode ¶
func (c *StatusConsistentStub) AddNode(nodeIDs ...string) error
AddNode add one or more nodes whose status you care about
func (*StatusConsistentStub) DeleteNode ¶
func (c *StatusConsistentStub) DeleteNode(nodeIDs ...string) error
DeleteNode delete one or more nodes whose status you no longer care about
func (*StatusConsistentStub) GetNodesWithActiveState ¶
func (c *StatusConsistentStub) GetNodesWithActiveState() []consensuspb.ConsensusNodeInfo
GetNodesWithActiveState get active information of all nodes you know including yourself First get the connection information of each node to other nodes, then take the intersection of the connection information of all nodes Note: if a node has no connection information for other nodes and the status of this node is not active then it is determined that this node has been disconnected, and no intersection will be performed
func (*StatusConsistentStub) IsRunning ¶
func (c *StatusConsistentStub) IsRunning() bool
IsRunning check whether consistent stub is running or not
func (*StatusConsistentStub) ResetNodes ¶
func (c *StatusConsistentStub) ResetNodes(nodes []string)
ResetNodes reset the node injected in consistent
func (*StatusConsistentStub) Start ¶
func (c *StatusConsistentStub) Start() error
Start start the status consistent service
func (*StatusConsistentStub) Stop ¶
func (c *StatusConsistentStub) Stop() error
Stop stop the status consistent service