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

33 lines
779 B
Go
Raw Permalink Normal View History

2020-12-12 18:59:40 +00:00
package network
import (
pbNet "github.com/asim/go-micro/v3/network/proto"
"github.com/asim/go-micro/v3/network/router"
)
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{
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 {
return router.Route{
Service: route.Service,
Address: route.Address,
Gateway: route.Gateway,
Network: route.Network,
Router: route.Router,
Link: route.Link,
Metric: route.Metric,
}
}