2020-12-12 18:59:40 +00:00
|
|
|
package network
|
2020-01-10 11:57:34 +00:00
|
|
|
|
|
|
|
import (
|
2021-01-20 13:54:31 +00:00
|
|
|
pbNet "github.com/asim/go-micro/v3/network/proto"
|
|
|
|
"github.com/asim/go-micro/v3/network/router"
|
2020-01-10 11:57:34 +00:00
|
|
|
)
|
|
|
|
|
2020-12-12 18:59:40 +00:00
|
|
|
// routeToProto encodes route into protobuf and returns it
|
|
|
|
func routeToProto(route router.Route) *pbNet.Route {
|
|
|
|
return &pbNet.Route{
|
2020-01-10 11:57:34 +00:00
|
|
|
Service: route.Service,
|
|
|
|
Address: route.Address,
|
|
|
|
Gateway: route.Gateway,
|
|
|
|
Network: route.Network,
|
|
|
|
Router: route.Router,
|
|
|
|
Link: route.Link,
|
|
|
|
Metric: int64(route.Metric),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-12 18:59:40 +00:00
|
|
|
// protoToRoute decodes protobuf route into router route and returns it
|
|
|
|
func protoToRoute(route *pbNet.Route) router.Route {
|
2020-01-10 11:57:34 +00:00
|
|
|
return router.Route{
|
|
|
|
Service: route.Service,
|
|
|
|
Address: route.Address,
|
|
|
|
Gateway: route.Gateway,
|
|
|
|
Network: route.Network,
|
|
|
|
Router: route.Router,
|
|
|
|
Link: route.Link,
|
|
|
|
Metric: route.Metric,
|
|
|
|
}
|
|
|
|
}
|