Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network struct { Nodes []*Node NetworkType string // "tcp" or "unix" GossipInterval time.Duration // The length of a round of gossip Stopper *util.Stopper }
Network provides access to a test gossip network of nodes.
func NewNetwork ¶
NewNetwork creates nodeCount gossip nodes. The networkType should be set to either "tcp" or "unix". The gossipInterval should be set to a compressed simulation timescale, though large enough to give the concurrent goroutines enough time to pass data back and forth in order to yield accurate estimates of how old data actually ends up being at the various nodes (e.g. DefaultTestGossipInterval).
func (*Network) GetNodeFromAddr ¶
GetNodeFromAddr returns the simulation node associated with provided network address, or nil if there is no such node.
func (*Network) GetNodeFromID ¶
GetNodeFromID returns the simulation node associated with provided node ID, or nil if there is no such node.
func (*Network) RunUntilFullyConnected ¶
RunUntilFullyConnected blocks until the gossip network has received gossip from every other node in the network. It returns the gossip cycle at which the network became fully connected.
func (*Network) SimulateNetwork ¶
SimulateNetwork runs a number of gossipInterval periods within the given Network. After each gossipInterval period, simCallback is invoked. When it returns false, the simulation ends. If it returns true, the simulation continues another cycle.
Node0 gossips the node count as well as the gossip sentinel. The gossip bootstrap hosts are set to the first three nodes (or fewer if less than three are available).
At each cycle of the simulation, node 0 gossips the sentinel. If the simulation requires other nodes to gossip, this should be done via simCallback.
The simulation callback receives a map of nodes, keyed by node address.