1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-17 17:44:30 +02:00
go-micro/network/util.go
Asim Aslam d94936f6c9
v3 (#2104)
* v3

* revert plugins

* fixup some issues
2021-01-20 13:54:31 +00:00

33 lines
779 B
Go

package network
import (
pbNet "github.com/asim/go-micro/v3/network/proto"
"github.com/asim/go-micro/v3/network/router"
)
// routeToProto encodes route into protobuf and returns it
func routeToProto(route router.Route) *pbNet.Route {
return &pbNet.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 *pbNet.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,
}
}