Documentation ¶
Index ¶
- func CheckMembership(t *testing.T, top flow.IdentityList, all flow.IdentityList)
- func CheckTopologySize(t *testing.T, total int, top flow.IdentityList)
- func ClusterNum(t *testing.T, ids flow.IdentityList, size int) int
- func Connected(t *testing.T, adjMap map[flow.Identifier]flow.IdentityList, ...)
- func LinearFanout(size int) int
- func MockStateForCollectionNodes(t *testing.T, collectorIds flow.IdentityList, clusterNum uint) (protocol.State, flow.ClusterList)
- func MockSubscriptionManager(t *testing.T, ids flow.IdentityList) []network.SubscriptionManager
- type Cache
- type FanoutFunc
- type RandomizedTopology
- type TopicBasedTopology
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMembership ¶
func CheckMembership(t *testing.T, top flow.IdentityList, all flow.IdentityList)
CheckMembership checks each identity in a top list belongs to all identity list.
func CheckTopologySize ¶
func CheckTopologySize(t *testing.T, total int, top flow.IdentityList)
TODO: fix this test after we have fanout optimized. CheckTopologySize evaluates that overall topology size of a node is bound by the fanout of system.
func ClusterNum ¶
ClusterNum is a test helper determines the number of clusters of specific `size`.
func Connected ¶ added in v0.14.0
func Connected(t *testing.T, adjMap map[flow.Identifier]flow.IdentityList, ids flow.IdentityList, f flow.IdentityFilter)
Connected checks if the graph represented by the adjacency matrix is connected. It traverses the adjacency map starting from an arbitrary node and checks if all nodes that satisfy the filter were visited.
func LinearFanout ¶
LinearFanoutFunc guarantees full network connectivity in a deterministic way. Given system of `size` nodes, it returns `size+1/2`.
func MockStateForCollectionNodes ¶ added in v0.14.0
func MockStateForCollectionNodes(t *testing.T, collectorIds flow.IdentityList, clusterNum uint) (protocol.State, flow.ClusterList)
MockStateForCollectionNodes is a test helper function that generate a mock state clustering collection nodes into `clusterNum` clusters.
func MockSubscriptionManager ¶
func MockSubscriptionManager(t *testing.T, ids flow.IdentityList) []network.SubscriptionManager
MockSubscriptionManager returns a list of mocked subscription manages for the input identities. It only mocks the Channels method of the subscription manager. Other methods return an error, as they are not supposed to be invoked.
Types ¶
type Cache ¶ added in v0.14.0
type Cache struct {
// contains filtered or unexported fields
}
Cache provides caching the most recently generated topology. It implements the same GenerateFanout as a normal topology, so can easily replace any topology implementation. As long as the input IdentityList to it is the same, the cached topology is returned without invoking the underlying GenerateFanout. This is vital to provide a deterministic topology interface, as by its nature, the Topology interface does not guarantee a deterministic behavior.
Note: as a convention with other topology implementations, Cache is not concurrency-safe, and should be invoked in a concurrency safe way, i.e., the caller should lock for it.
func NewCache ¶ added in v0.14.0
NewCache creates and returns a topology Cache given an instance of topology implementation.
func (*Cache) GenerateFanout ¶ added in v0.14.0
func (c *Cache) GenerateFanout(ids flow.IdentityList, channels network.ChannelList) (flow.IdentityList, error)
GenerateFanout receives IdentityList of entire network and constructs the fanout IdentityList of this instance. It caches the most recently generated fanout list, so as long as the input list is the same, it returns the same output. It invalidates and updates its internal cache the first time input list changes. A node directly communicates with its fanout IdentityList on epidemic dissemination of the messages (i.e., publish and multicast). Independent invocations of GenerateFanout on different nodes collaboratively must construct a cohesive connected graph of nodes that enables them talking to each other.
Note that this implementation of GenerateFanout preserves same output as long as input is the same. This should not be assumed as a 1-1 mapping between input and output.
type FanoutFunc ¶
FanoutFunc represents a function type that receiving total number of nodes in flow system, returns fanout of individual nodes.
type RandomizedTopology ¶ added in v0.14.0
type RandomizedTopology struct {
// contains filtered or unexported fields
}
RandomizedTopology generates a random topology per channel. By random topology we mean a node is connected to any other co-channel nodes with some edge probability.
func NewRandomizedTopology ¶ added in v0.14.0
func NewRandomizedTopology(nodeID flow.Identifier, logger zerolog.Logger, edgeProb float64, state protocol.State) (*RandomizedTopology, error)
NewRandomizedTopology returns an instance of the RandomizedTopology.
func (RandomizedTopology) GenerateFanout ¶ added in v0.14.0
func (r RandomizedTopology) GenerateFanout(ids flow.IdentityList, channels network.ChannelList) (flow.IdentityList, error)
GenerateFanout receives IdentityList of entire network and constructs the fanout IdentityList of this instance. A node directly communicates with its fanout IdentityList on epidemic dissemination of the messages (i.e., publish and multicast). Independent invocations of GenerateFanout on different nodes collaboratively must construct a cohesive connected graph of nodes that enables them talking to each other. This should be done with a very high probability in randomized topology.
type TopicBasedTopology ¶
type TopicBasedTopology struct {
// contains filtered or unexported fields
}
TopicBasedTopology is a deterministic topology mapping that creates a connected graph component among the nodes involved in each topic.
func NewTopicBasedTopology ¶
func NewTopicBasedTopology(nodeID flow.Identifier, logger zerolog.Logger, state protocol.State) (*TopicBasedTopology, error)
NewTopicBasedTopology returns an instance of the TopicBasedTopology.
func (TopicBasedTopology) GenerateFanout ¶
func (t TopicBasedTopology) GenerateFanout(ids flow.IdentityList, channels network.ChannelList) (flow.IdentityList, error)
GenerateFanout receives IdentityList of entire network and constructs the fanout IdentityList of this instance. A node directly communicates with its fanout IdentityList on epidemic dissemination of the messages (i.e., publish and multicast). Independent invocations of GenerateFanout on different nodes collaboratively must construct a cohesive connected graph of nodes that enables them talking to each other.