Documentation ¶
Index ¶
- type Network
- func (n *Network) Add(id raft.ServerID, trans raft.Transport) raft.Transport
- func (n *Network) Address(id raft.ServerID) raft.ServerAddress
- func (n *Network) ConnectAllServers(id raft.ServerID)
- func (n *Network) Deposing(id raft.ServerID)
- func (n *Network) Disconnect(id, follower raft.ServerID)
- func (n *Network) Electing(id raft.ServerID)
- func (n *Network) HasAppendedLogsFromTo(id1, id2 raft.ServerID) bool
- func (n *Network) PeerConnected(id, peer raft.ServerID) bool
- func (n *Network) Reconnect(id, follower raft.ServerID)
- func (n *Network) ScheduleAppendFailure(id raft.ServerID, command uint64) *event.Event
- func (n *Network) ScheduleEnqueueFailure(id raft.ServerID, command uint64) *event.Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network provides control over all transports of a cluster, injecting disconnections and failures.
func New ¶
func New(logger hclog.Logger) *Network
New create a new network for controlling the underlying transports.
func (*Network) Add ¶
Add a new transport to the network. Returns a transport that wraps the given transport with instrumentation to inject disconnections and failures.
func (*Network) Address ¶
func (n *Network) Address(id raft.ServerID) raft.ServerAddress
Address returns the address of the server with the given id.
func (*Network) ConnectAllServers ¶
ConnectAllServers establishes full cluster connectivity after an election. The given ID is the one of the leader, which is already connected.
func (*Network) Deposing ¶
Deposing disables connectivity from the transport of the server with the given ID to all its peers, allowing only append entries RPCs for peers that are lagging behind in terms of applied logs to be performed.
func (*Network) Disconnect ¶
Disconnect disables connectivity from the transport of the leader server with the given ID to the peer with the given ID.
func (*Network) Electing ¶
Electing resets any leader-related state in the transport associated with given server ID (such as the track of logs appended by the peers), and it connects the transport to all its peers, enabling it to send them RPCs. It must be called whenever the server associated with this transport is about to transition to the leader state, and before any append entries RPC is made.
func (*Network) HasAppendedLogsFromTo ¶
HasAppendedLogsFromTo returns true if at least one log entry has been appended by server with id1 to server with id2.
It is assumed that id1 is a leader that has just been elected and has been trying to append a noop log to all its followers.
func (*Network) PeerConnected ¶
PeerConnected returns whether the peer with the given server ID is connected with the transport of the server with the given ID.
func (*Network) Reconnect ¶
Reconnect re-enables connectivity from the transport of the leader server with the given ID to the peer with the given ID.
func (*Network) ScheduleAppendFailure ¶
ScheduleAppendFailure will make all followers of the given leader server append the n'th log command sent by the leader, but they will fail to acknowledge the leader about it. Return an event that will fire when all of them have failed and will block them all until acknowledged.
func (*Network) ScheduleEnqueueFailure ¶
ScheduleEnqueueFailure will make all followers of the given server fail when the leader tries to append the n'th log command. Return an event that will fire when all of them have failed and will block them all until acknowledged.