Added sync message. Refactored connect flow. Adverts are gossipped.
This commit adds a Sync message which is sent as a reply to Connect message. This should in theory speed up convergence of a (re)connecting node. We respond to Sync message by sending a peer message back to the peer origin of the Sync message. We consequently update our routing table and peer graph with the data sent in via Sync message. We now gossip advertse to up to 3 randomly selected peers instead of sending a multicast message to the network. Equally, Solicitation i.e. full table adverts are gossipped to a randomly selected peer. If that fails we send a multicast message to the network.
This commit is contained in:
33
util/proto/proto.go
Normal file
33
util/proto/proto.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Package proto contains utility functions for working with protobufs
|
||||
package proto
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/router"
|
||||
pbRtr "github.com/micro/go-micro/router/service/proto"
|
||||
)
|
||||
|
||||
// RouteToProto encodes route into protobuf and returns it
|
||||
func RouteToProto(route router.Route) *pbRtr.Route {
|
||||
return &pbRtr.Route{
|
||||
Service: route.Service,
|
||||
Address: route.Address,
|
||||
Gateway: route.Gateway,
|
||||
Network: route.Network,
|
||||
Router: route.Router,
|
||||
Link: route.Link,
|
||||
Metric: int64(route.Metric),
|
||||
}
|
||||
}
|
||||
|
||||
// ProtoToRoute decodes protobuf route into router route and returns it
|
||||
func ProtoToRoute(route *pbRtr.Route) router.Route {
|
||||
return router.Route{
|
||||
Service: route.Service,
|
||||
Address: route.Address,
|
||||
Gateway: route.Gateway,
|
||||
Network: route.Network,
|
||||
Router: route.Router,
|
||||
Link: route.Link,
|
||||
Metric: route.Metric,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user