Version: v3.0.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 26 Imported by: 0




This section is empty.


View Source
var (
	// DefaultName is default network name
	DefaultName = "go.micro"
	// DefaultAddress is default network address
	DefaultAddress = ":0"
	// AnnounceTime defines time interval to periodically announce node neighbours
	AnnounceTime = 1 * time.Second
	// KeepAliveTime is the time in which we want to have sent a message to a peer
	KeepAliveTime = 30 * time.Second
	// SyncTime is the time a network node requests full sync from the network
	SyncTime = 1 * time.Minute
	// PruneTime defines time interval to periodically check nodes that need to be pruned
	// due to their not announcing their presence within this time interval
	PruneTime = 90 * time.Second
	// MaxDepth defines max depth of peer topology
	MaxDepth uint = 3
	// NetworkChannel is the name of the tunnel channel for passing network messages
	NetworkChannel = "network"
	// ControlChannel is the name of the tunnel channel for passing control message
	ControlChannel = "control"
	// DefaultLink is default network link
	DefaultLink = "network"
	// MaxConnections is the max number of network client connections
	MaxConnections = 3
	// MaxPeerErrors is the max number of peer errors before we remove it from network graph
	MaxPeerErrors = 3
	// ErrPeerExists is returned when adding a peer which already exists
	ErrPeerExists = errors.New("peer already exists")
	// ErrPeerNotFound is returned when a peer could not be found in node topology
	ErrPeerNotFound = errors.New("peer not found")
	// ErrClientNotFound is returned when client for tunnel channel could not be found
	ErrClientNotFound = errors.New("client not found")
	// ErrPeerLinkNotFound is returned when peer link could not be found in tunnel Links
	ErrPeerLinkNotFound = errors.New("peer link not found")
	// ErrPeerMaxExceeded is returned when peer has reached its max error count limit
	ErrPeerMaxExceeded = errors.New("peer max errors exceeded")


func NewNetwork

func NewNetwork(opts network.Network

NewNetwork returns a new network node

func PeersToProto

func PeersToProto(node network.Node, depth uint) *pb.Peer

PeersToProto returns node peers graph encoded into protobuf

func ProtoToRoute

func ProtoToRoute(route *pb.Route) router.Route

ProtoToRoute decodes protobuf route into router route and returns it

func RouteToProto

func RouteToProto(route router.Route) *pb.Route

RouteToProto encodes route into protobuf and returns it

func UnpackPeerTopology

func UnpackPeerTopology(pbPeer *pb.Peer, lastSeen time.Time, depth uint) *node

UnpackPeerTopology unpacks pb.Peer into node topology of given depth


This section is empty.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL