Merge pull request #1104 from milosgajdos83/network-hackery

[WIP] Network hackery
This commit is contained in:
Asim Aslam
2020-01-14 20:28:32 +00:00
committed by GitHub
10 changed files with 860 additions and 123 deletions

33
util/proto/proto.go Normal file
View 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,
}
}