Documentation ¶
Index ¶
- func LinearTopology(n int, clk clock.Clock) (*Topology, []*Peer, error)
- func NewPeerID() (kadt.PeerID, error)
- type DefaultLink
- type Link
- type Peer
- type Router
- func (r *Router) AddToPeerStore(ctx context.Context, id kadt.PeerID) error
- func (r *Router) GetClosestNodes(ctx context.Context, to kadt.PeerID, target kadt.Key) ([]kadt.PeerID, error)
- func (r *Router) NodeID() kad.NodeID[kadt.Key]
- func (r *Router) SendMessage(ctx context.Context, to kadt.PeerID, req *pb.Message) (*pb.Message, error)
- type Topology
- func (t *Topology) ConnectPeers(a *Peer, b *Peer)
- func (t *Topology) ConnectPeersWithRoute(a *Peer, b *Peer, l Link)
- func (t *Topology) Dial(ctx context.Context, from kadt.PeerID, to kadt.PeerID) error
- func (t *Topology) Peers() []*Peer
- func (t *Topology) RouteMessage(ctx context.Context, from kadt.PeerID, to kadt.PeerID, req *pb.Message) (*pb.Message, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LinearTopology ¶
LinearTopology creates a network topology consisting of n nodes peered in a linear chain. The nodes are configured with routing tables that contain immediate neighbours. It returns the topology and the nodes ordered such that nodes[x] has nodes[x-1] and nodes[x+1] in its routing table The topology is not a ring: nodes[0] only has nodes[1] in its table and nodes[n-1] only has nodes[n-2] in its table. nodes[1] has nodes[0] and nodes[2] in its routing table. If n > 2 then the first and last nodes will not have one another in their routing tables.
Types ¶
type DefaultLink ¶
type DefaultLink struct{}
DefaultLink is the default link used if none is specified. It has zero latency and always succeeds.
func (*DefaultLink) ConnLatency ¶
func (l *DefaultLink) ConnLatency() time.Duration
func (*DefaultLink) DialErr ¶
func (l *DefaultLink) DialErr() error
func (*DefaultLink) DialLatency ¶
func (l *DefaultLink) DialLatency() time.Duration
type Link ¶
type Link interface { ConnLatency() time.Duration // the simulated time taken to return an error or successful outcome DialLatency() time.Duration // the simulated time taken to connect to a node DialErr() error // an error that should be returned on dial, nil if the dial is successful }
Link represents the route between two nodes. It allows latency and transport failures to be simulated.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AddToPeerStore ¶
func (*Router) GetClosestNodes ¶
type Topology ¶
type Topology struct {
// contains filtered or unexported fields
}