Changed RPC methods. Changed Network interface.

* Nodes/Topology removed from public methods from Network interface
* Peers() returns max depth 3 topology
* handler.Topology rpc endpoint removed
* handler.Peers rpc endpoint accept "depth" param to return max depth peers
This commit is contained in:
Milos Gajdos 2019-09-11 23:03:27 +01:00
parent 588484c3bf
commit d6be91e8af
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F
8 changed files with 132 additions and 440 deletions

View File

@ -809,16 +809,6 @@ func (n *network) Connect() error {
return nil
}
// Nodes returns a list of all network nodes
func (n *network) Nodes() []Node {
return n.node.Nodes()
}
// Topology returns network topology
func (n *network) Topology() Node {
return n.node.Topology(MaxDepth)
}
func (n *network) close() error {
// stop the server
if err := n.server.Stop(); err != nil {

View File

@ -15,84 +15,62 @@ type Network struct {
Network network.Network
}
// ListNodes returns a list of all accessible nodes in the network
func (n *Network) ListNodes(ctx context.Context, req *pbNet.ListRequest, resp *pbNet.ListResponse) error {
networkNodes := n.Network.Nodes()
var nodes []*pbNet.Node
for _, networkNode := range networkNodes {
node := &pbNet.Node{
Id: networkNode.Id(),
Address: networkNode.Address(),
}
nodes = append(nodes, node)
// toplogyToProto recursively traverses node topology and returns it
func peerTopology(peer network.Node, depth uint) *pbNet.Peer {
node := &pbNet.Node{
Id: peer.Id(),
Address: peer.Address(),
}
resp.Nodes = nodes
pbPeers := &pbNet.Peer{
Node: node,
Peers: make([]*pbNet.Peer, 0),
}
return nil
// return if we reached the end of topology or depth
if depth == 0 || len(peer.Peers()) == 0 {
return pbPeers
}
// decrement the depth
depth--
// iterate through peers of peers aka pops
for _, pop := range peer.Peers() {
peer := peerTopology(pop, depth)
pbPeers.Peers = append(pbPeers.Peers, peer)
}
return pbPeers
}
// ListPeers returns a list of all the nodes the node has a direct link with
func (n *Network) ListPeers(ctx context.Context, req *pbNet.PeerRequest, resp *pbNet.PeerResponse) error {
depth := uint(req.Depth)
if depth <= 0 || depth > network.MaxDepth {
depth = network.MaxDepth
}
// get node peers
nodePeers := n.Network.Peers()
var peers []*pbNet.Node
for _, nodePeer := range nodePeers {
peer := &pbNet.Node{
Id: nodePeer.Id(),
Address: nodePeer.Address(),
}
peers = append(peers, peer)
}
resp.Peers = peers
return nil
}
// toplogyToProto recursively traverses node topology and returns it
func toplogyToProto(node network.Node, pbPeer *pbNet.Peer) *pbNet.Peer {
// return if we reached the end of topology
if len(node.Peers()) == 0 {
return pbPeer
}
for _, topNode := range node.Peers() {
pbNode := &pbNet.Node{
Id: topNode.Id(),
Address: topNode.Address(),
}
pbPeer := &pbNet.Peer{
Node: pbNode,
Peers: make([]*pbNet.Peer, 0),
}
peer := toplogyToProto(topNode, pbPeer)
pbPeer.Peers = append(pbPeer.Peers, peer)
}
return pbPeer
}
// Topology returns a list of nodes in node topology i.e. it returns all (in)directly reachable nodes from this node
func (n *Network) Topology(ctx context.Context, req *pbNet.TopologyRequest, resp *pbNet.TopologyResponse) error {
// get node topology
topNode := n.Network.Topology()
// network node aka root node
node := &pbNet.Node{
Id: n.Network.Id(),
Address: n.Network.Address(),
}
// we will build proto topology into this
pbPeer := &pbNet.Peer{
peers := &pbNet.Peer{
Node: node,
Peers: make([]*pbNet.Peer, 0),
}
// return topology encoded into protobuf
topology := toplogyToProto(topNode, pbPeer)
resp.Topology = topology
for _, nodePeer := range nodePeers {
peer := peerTopology(nodePeer, depth)
peers.Peers = append(peers.Peers, peer)
}
resp.Peers = peers
return nil
}

View File

@ -44,10 +44,6 @@ type Network interface {
Name() string
// Connect starts the resolver and tunnel server
Connect() error
// Nodes returns list of network nodes
Nodes() []Node
// Topology returns node topology up to MaxDepth hops
Topology() Node
// Close stops the tunnel and resolving
Close() error
// Client is micro client

View File

@ -47,11 +47,11 @@ func (n *node) Network() Network {
// Nodes returns a slice if all nodes in node topology
func (n *node) Nodes() []Node {
// we need to freeze the network graph here
// otherwise we might get invalid results
// otherwise we might get inconsisten results
n.RLock()
defer n.RUnlock()
//track the visited nodes
// track the visited nodes
visited := make(map[string]*node)
// queue of the nodes to visit
queue := list.New()
@ -86,32 +86,8 @@ func (n *node) Nodes() []Node {
return nodes
}
// Peers returns node peers
func (n *node) Peers() []Node {
var peers []Node
n.RLock()
for _, peer := range n.peers {
// make a copy of the node
p := &node{
id: peer.id,
address: peer.address,
peers: make(map[string]*node),
network: peer.network,
}
// collect peer's peers aka pop (peer of peer)
for id, pop := range peer.peers {
p.peers[id] = pop
}
peers = append(peers, p)
}
n.RUnlock()
return peers
}
// topology returns network topology up to MaxDepth
func (n *node) Topology(depth uint) *node {
n.RLock()
// topology returns node topology down to given depth
func (n *node) topology(depth uint) *node {
// make a copy of yourself
node := &node{
id: n.id,
@ -125,15 +101,31 @@ func (n *node) Topology(depth uint) *node {
return node
}
// decrement the depth
depth--
// iterate through our peers and update the node peers
for _, peer := range n.peers {
nodePeer := peer.Topology(depth)
node.peers[nodePeer.id] = nodePeer
nodePeer := peer.topology(depth)
if _, ok := node.peers[nodePeer.id]; !ok {
node.peers[nodePeer.id] = nodePeer
}
}
return node
}
// Peers returns node peers
func (n *node) Peers() []Node {
n.RLock()
var peers []Node
for _, nodePeer := range n.peers {
peer := nodePeer.topology(MaxDepth)
peers = append(peers, peer)
}
n.RUnlock()
return node
return peers
}
// getProtoTopology returns node topology down to the given depth encoded in protobuf

View File

@ -118,6 +118,22 @@ func TestNodes(t *testing.T) {
}
}
func collectPeerIds(peer Node, ids map[string]bool) map[string]bool {
if len(peer.Peers()) == 0 {
return ids
}
// iterate through the whole graph
for _, peer := range peer.Peers() {
ids = collectPeerIds(peer, ids)
if _, ok := ids[peer.Id()]; !ok {
ids[peer.Id()] = true
}
}
return ids
}
func TestPeers(t *testing.T) {
// single node
single := &node{
@ -126,107 +142,44 @@ func TestPeers(t *testing.T) {
peers: make(map[string]*node),
network: newNetwork(Name(testNodeNetName)),
}
// get all the nodes including yourself
// get node peers
peers := single.Peers()
// there should be no peers
peerCount := 0
if len(peers) != peerCount {
t.Errorf("Expected to find %d peers, found: %d", peerCount, len(peers))
t.Errorf("Expected to find %d nodes, found: %d", peerCount, len(peers))
}
// complicated node graph
node := testSetup()
// get all the nodes including yourself
peers = node.Peers()
// compile a list of ids of all nodes in the network into map for easy indexing
// list of ids of nodes of MaxDepth
peerIds := make(map[string]bool)
// add peer Ids
for _, id := range testNodePeerIds {
peerIds[id] = true
}
// we should return the correct number of peers
if len(peers) != len(peerIds) {
t.Errorf("Expected %d nodes, found: %d", len(peerIds), len(peers))
}
// iterate through the list of peers and makes sure all have been returned
for _, peer := range peers {
if _, ok := peerIds[peer.Id()]; !ok {
t.Errorf("Expected to find %s peer", peer.Id())
}
}
}
func collectTopologyIds(peers map[string]*node, ids map[string]bool) map[string]bool {
if len(peers) == 0 {
return ids
}
// iterate through the whole graph
for id, peer := range peers {
ids = collectTopologyIds(peer.peers, ids)
if _, ok := ids[id]; !ok {
ids[id] = true
}
}
return ids
}
func TestTopology(t *testing.T) {
// single node
single := &node{
id: testNodeId,
address: testNodeAddress,
peers: make(map[string]*node),
network: newNetwork(Name(testNodeNetName)),
}
// get all the nodes including yourself
topology := single.Topology(MaxDepth)
// you should not be in your topology
topCount := 0
if len(topology.peers) != topCount {
t.Errorf("Expected to find %d nodes, found: %d", topCount, len(topology.peers))
}
// complicated node graph
node := testSetup()
// list of ids of nodes of depth 1 i.e. node peers
peerIds := make(map[string]bool)
// add peer Ids
for _, id := range testNodePeerIds {
peerIds[id] = true
}
topology = node.Topology(1)
// depth 1 should return only immediate peers
if len(topology.peers) != len(peerIds) {
t.Errorf("Expected to find %d nodes, found: %d", len(peerIds), len(topology.peers))
}
for id := range topology.peers {
if _, ok := peerIds[id]; !ok {
t.Errorf("Expected to find %s peer", id)
}
}
// add peers of peers to peerIds
for _, id := range testPeerOfPeerIds {
peerIds[id] = true
}
topology = node.Topology(2)
// get node peers
peers = node.Peers()
topIds := make(map[string]bool)
topIds = collectTopologyIds(topology.peers, topIds)
if len(topIds) != len(peerIds) {
t.Errorf("Expected to find %d nodes, found: %d", len(peerIds), len(topIds))
// we will collect all returned Peer Ids into this map
resPeerIds := make(map[string]bool)
for _, peer := range peers {
resPeerIds[peer.Id()] = true
resPeerIds = collectPeerIds(peer, resPeerIds)
}
for id := range topIds {
if _, ok := topIds[id]; !ok {
// if correct, we must collect all peerIds
if len(resPeerIds) != len(peerIds) {
t.Errorf("Expected to find %d peers, found: %d", len(peerIds), len(resPeerIds))
}
for id := range resPeerIds {
if _, ok := peerIds[id]; !ok {
t.Errorf("Expected to find %s peer", id)
}
}

View File

@ -35,9 +35,7 @@ var _ server.Option
// Client API for Network service
type NetworkService interface {
ListNodes(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
ListPeers(ctx context.Context, in *PeerRequest, opts ...client.CallOption) (*PeerResponse, error)
Topology(ctx context.Context, in *TopologyRequest, opts ...client.CallOption) (*TopologyResponse, error)
ListRoutes(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.ListResponse, error)
}
@ -59,16 +57,6 @@ func NewNetworkService(name string, c client.Client) NetworkService {
}
}
func (c *networkService) ListNodes(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "Network.ListNodes", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *networkService) ListPeers(ctx context.Context, in *PeerRequest, opts ...client.CallOption) (*PeerResponse, error) {
req := c.c.NewRequest(c.name, "Network.ListPeers", in)
out := new(PeerResponse)
@ -79,16 +67,6 @@ func (c *networkService) ListPeers(ctx context.Context, in *PeerRequest, opts ..
return out, nil
}
func (c *networkService) Topology(ctx context.Context, in *TopologyRequest, opts ...client.CallOption) (*TopologyResponse, error) {
req := c.c.NewRequest(c.name, "Network.Topology", in)
out := new(TopologyResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *networkService) ListRoutes(ctx context.Context, in *proto1.Request, opts ...client.CallOption) (*proto1.ListResponse, error) {
req := c.c.NewRequest(c.name, "Network.ListRoutes", in)
out := new(proto1.ListResponse)
@ -102,17 +80,13 @@ func (c *networkService) ListRoutes(ctx context.Context, in *proto1.Request, opt
// Server API for Network service
type NetworkHandler interface {
ListNodes(context.Context, *ListRequest, *ListResponse) error
ListPeers(context.Context, *PeerRequest, *PeerResponse) error
Topology(context.Context, *TopologyRequest, *TopologyResponse) error
ListRoutes(context.Context, *proto1.Request, *proto1.ListResponse) error
}
func RegisterNetworkHandler(s server.Server, hdlr NetworkHandler, opts ...server.HandlerOption) error {
type network interface {
ListNodes(ctx context.Context, in *ListRequest, out *ListResponse) error
ListPeers(ctx context.Context, in *PeerRequest, out *PeerResponse) error
Topology(ctx context.Context, in *TopologyRequest, out *TopologyResponse) error
ListRoutes(ctx context.Context, in *proto1.Request, out *proto1.ListResponse) error
}
type Network struct {
@ -126,18 +100,10 @@ type networkHandler struct {
NetworkHandler
}
func (h *networkHandler) ListNodes(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.NetworkHandler.ListNodes(ctx, in, out)
}
func (h *networkHandler) ListPeers(ctx context.Context, in *PeerRequest, out *PeerResponse) error {
return h.NetworkHandler.ListPeers(ctx, in, out)
}
func (h *networkHandler) Topology(ctx context.Context, in *TopologyRequest, out *TopologyResponse) error {
return h.NetworkHandler.Topology(ctx, in, out)
}
func (h *networkHandler) ListRoutes(ctx context.Context, in *proto1.Request, out *proto1.ListResponse) error {
return h.NetworkHandler.ListRoutes(ctx, in, out)
}

View File

@ -21,83 +21,10 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Empty request
type ListRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListRequest) Reset() { *m = ListRequest{} }
func (m *ListRequest) String() string { return proto.CompactTextString(m) }
func (*ListRequest) ProtoMessage() {}
func (*ListRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{0}
}
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListRequest.Unmarshal(m, b)
}
func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic)
}
func (m *ListRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListRequest.Merge(m, src)
}
func (m *ListRequest) XXX_Size() int {
return xxx_messageInfo_ListRequest.Size(m)
}
func (m *ListRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ListRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ListRequest proto.InternalMessageInfo
// ListResponse is returned by ListNodes
type ListResponse struct {
// network nodes
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ListResponse) Reset() { *m = ListResponse{} }
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
func (*ListResponse) ProtoMessage() {}
func (*ListResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{1}
}
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ListResponse.Unmarshal(m, b)
}
func (m *ListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ListResponse.Marshal(b, m, deterministic)
}
func (m *ListResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ListResponse.Merge(m, src)
}
func (m *ListResponse) XXX_Size() int {
return xxx_messageInfo_ListResponse.Size(m)
}
func (m *ListResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ListResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ListResponse proto.InternalMessageInfo
func (m *ListResponse) GetNodes() []*Node {
if m != nil {
return m.Nodes
}
return nil
}
// PeerRequest requests list of peers
type PeerRequest struct {
// node id
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// node topology depth
Depth uint32 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -107,7 +34,7 @@ func (m *PeerRequest) Reset() { *m = PeerRequest{} }
func (m *PeerRequest) String() string { return proto.CompactTextString(m) }
func (*PeerRequest) ProtoMessage() {}
func (*PeerRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{2}
return fileDescriptor_8571034d60397816, []int{0}
}
func (m *PeerRequest) XXX_Unmarshal(b []byte) error {
@ -128,16 +55,17 @@ func (m *PeerRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_PeerRequest proto.InternalMessageInfo
func (m *PeerRequest) GetId() string {
func (m *PeerRequest) GetDepth() uint32 {
if m != nil {
return m.Id
return m.Depth
}
return ""
return 0
}
// PeerResponse is returned by ListPeers
type PeerResponse struct {
Peers []*Node `protobuf:"bytes,1,rep,name=peers,proto3" json:"peers,omitempty"`
// return peer topology
Peers *Peer `protobuf:"bytes,1,opt,name=peers,proto3" json:"peers,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -147,7 +75,7 @@ func (m *PeerResponse) Reset() { *m = PeerResponse{} }
func (m *PeerResponse) String() string { return proto.CompactTextString(m) }
func (*PeerResponse) ProtoMessage() {}
func (*PeerResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{3}
return fileDescriptor_8571034d60397816, []int{1}
}
func (m *PeerResponse) XXX_Unmarshal(b []byte) error {
@ -168,94 +96,13 @@ func (m *PeerResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_PeerResponse proto.InternalMessageInfo
func (m *PeerResponse) GetPeers() []*Node {
func (m *PeerResponse) GetPeers() *Peer {
if m != nil {
return m.Peers
}
return nil
}
// TopologyRequest list node topology
type TopologyRequest struct {
// node id
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *TopologyRequest) Reset() { *m = TopologyRequest{} }
func (m *TopologyRequest) String() string { return proto.CompactTextString(m) }
func (*TopologyRequest) ProtoMessage() {}
func (*TopologyRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{4}
}
func (m *TopologyRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TopologyRequest.Unmarshal(m, b)
}
func (m *TopologyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TopologyRequest.Marshal(b, m, deterministic)
}
func (m *TopologyRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_TopologyRequest.Merge(m, src)
}
func (m *TopologyRequest) XXX_Size() int {
return xxx_messageInfo_TopologyRequest.Size(m)
}
func (m *TopologyRequest) XXX_DiscardUnknown() {
xxx_messageInfo_TopologyRequest.DiscardUnknown(m)
}
var xxx_messageInfo_TopologyRequest proto.InternalMessageInfo
func (m *TopologyRequest) GetId() string {
if m != nil {
return m.Id
}
return ""
}
// TopologyResponse is returned by Topology
type TopologyResponse struct {
Topology *Peer `protobuf:"bytes,1,opt,name=topology,proto3" json:"topology,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *TopologyResponse) Reset() { *m = TopologyResponse{} }
func (m *TopologyResponse) String() string { return proto.CompactTextString(m) }
func (*TopologyResponse) ProtoMessage() {}
func (*TopologyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{5}
}
func (m *TopologyResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TopologyResponse.Unmarshal(m, b)
}
func (m *TopologyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_TopologyResponse.Marshal(b, m, deterministic)
}
func (m *TopologyResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_TopologyResponse.Merge(m, src)
}
func (m *TopologyResponse) XXX_Size() int {
return xxx_messageInfo_TopologyResponse.Size(m)
}
func (m *TopologyResponse) XXX_DiscardUnknown() {
xxx_messageInfo_TopologyResponse.DiscardUnknown(m)
}
var xxx_messageInfo_TopologyResponse proto.InternalMessageInfo
func (m *TopologyResponse) GetTopology() *Peer {
if m != nil {
return m.Topology
}
return nil
}
// Node is network node
type Node struct {
// node id
@ -271,7 +118,7 @@ func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{6}
return fileDescriptor_8571034d60397816, []int{2}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
@ -319,7 +166,7 @@ func (m *Connect) Reset() { *m = Connect{} }
func (m *Connect) String() string { return proto.CompactTextString(m) }
func (*Connect) ProtoMessage() {}
func (*Connect) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{7}
return fileDescriptor_8571034d60397816, []int{3}
}
func (m *Connect) XXX_Unmarshal(b []byte) error {
@ -360,7 +207,7 @@ func (m *Close) Reset() { *m = Close{} }
func (m *Close) String() string { return proto.CompactTextString(m) }
func (*Close) ProtoMessage() {}
func (*Close) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{8}
return fileDescriptor_8571034d60397816, []int{4}
}
func (m *Close) XXX_Unmarshal(b []byte) error {
@ -403,7 +250,7 @@ func (m *Peer) Reset() { *m = Peer{} }
func (m *Peer) String() string { return proto.CompactTextString(m) }
func (*Peer) ProtoMessage() {}
func (*Peer) Descriptor() ([]byte, []int) {
return fileDescriptor_8571034d60397816, []int{9}
return fileDescriptor_8571034d60397816, []int{5}
}
func (m *Peer) XXX_Unmarshal(b []byte) error {
@ -439,12 +286,8 @@ func (m *Peer) GetPeers() []*Peer {
}
func init() {
proto.RegisterType((*ListRequest)(nil), "go.micro.network.ListRequest")
proto.RegisterType((*ListResponse)(nil), "go.micro.network.ListResponse")
proto.RegisterType((*PeerRequest)(nil), "go.micro.network.PeerRequest")
proto.RegisterType((*PeerResponse)(nil), "go.micro.network.PeerResponse")
proto.RegisterType((*TopologyRequest)(nil), "go.micro.network.TopologyRequest")
proto.RegisterType((*TopologyResponse)(nil), "go.micro.network.TopologyResponse")
proto.RegisterType((*Node)(nil), "go.micro.network.Node")
proto.RegisterType((*Connect)(nil), "go.micro.network.Connect")
proto.RegisterType((*Close)(nil), "go.micro.network.Close")
@ -454,29 +297,24 @@ func init() {
func init() { proto.RegisterFile("network.proto", fileDescriptor_8571034d60397816) }
var fileDescriptor_8571034d60397816 = []byte{
// 371 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xc1, 0x4e, 0xc2, 0x40,
0x10, 0x86, 0xa1, 0x82, 0xc0, 0x20, 0x4a, 0xf6, 0x60, 0x1a, 0x12, 0x0c, 0xec, 0x89, 0x18, 0x2d,
0x06, 0xe2, 0xcd, 0x1b, 0x89, 0x5e, 0x08, 0x31, 0xe8, 0x03, 0x28, 0x74, 0x52, 0x1b, 0xa1, 0x53,
0x77, 0x97, 0x18, 0x9f, 0xcf, 0x17, 0x33, 0xbb, 0xdb, 0x52, 0x04, 0xaa, 0xe1, 0xd6, 0x9d, 0xf9,
0xe7, 0xfb, 0xb7, 0xb3, 0x33, 0xd0, 0x88, 0x50, 0x7d, 0x92, 0x78, 0xf7, 0x62, 0x41, 0x8a, 0x58,
0x33, 0x20, 0x6f, 0x19, 0xce, 0x05, 0x79, 0x49, 0xbc, 0x35, 0x0c, 0x42, 0xf5, 0xb6, 0x9a, 0x79,
0x73, 0x5a, 0xf6, 0x4d, 0xa6, 0x1f, 0xd0, 0xb5, 0xfd, 0x10, 0xb4, 0x52, 0x28, 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, 0x7a, 0x5a, 0x17, 0x79, 0x69, 0xfb, 0x16, 0xbc, 0x90, 0xd2,
0xb4, 0xd9, 0x5e, 0xda, 0xc6, 0xf8, 0xec, 0xa3, 0x6d, 0x8e, 0x0f, 0x2f, 0xb0, 0x27, 0xa8, 0xa6,
0xef, 0xcd, 0xba, 0xbb, 0xea, 0xad, 0x71, 0x69, 0xf1, 0xbf, 0x24, 0x6b, 0xe8, 0x03, 0x80, 0xb9,
0xb4, 0xde, 0x12, 0xc9, 0xdc, 0xac, 0x26, 0xd9, 0x9b, 0x94, 0xd6, 0xde, 0xc9, 0xfc, 0xfe, 0xd7,
0xd9, 0xb1, 0xd9, 0xb0, 0xe1, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x41, 0x11, 0x04, 0x65, 0xb9,
0x03, 0x00, 0x00,
// 292 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xcd, 0x4a, 0xc3, 0x40,
0x10, 0x36, 0x31, 0x31, 0x74, 0x6a, 0x45, 0x16, 0x91, 0x50, 0xa8, 0x94, 0xf5, 0x22, 0xa2, 0x1b,
0x69, 0xf0, 0xe6, 0xad, 0x07, 0x2f, 0xa5, 0x48, 0x9e, 0x40, 0x9b, 0x1d, 0xd2, 0xa0, 0xcd, 0xc4,
0xdd, 0x0d, 0xbe, 0x8e, 0x8f, 0x2a, 0xd9, 0x4d, 0x2d, 0x28, 0xa1, 0xf4, 0x96, 0xf9, 0xfe, 0x32,
0xc3, 0xb7, 0x30, 0xaa, 0xd0, 0x7c, 0x91, 0x7a, 0x17, 0xb5, 0x22, 0x43, 0xec, 0xbc, 0x20, 0xb1,
0x29, 0x73, 0x45, 0xa2, 0xc3, 0xc7, 0x69, 0x51, 0x9a, 0x75, 0xb3, 0x12, 0x39, 0x6d, 0x12, 0xcb,
0x24, 0x05, 0xdd, 0xbb, 0x0f, 0x45, 0x8d, 0x41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00, 0x00,
}

View File

@ -6,41 +6,20 @@ import "github.com/micro/go-micro/router/proto/router.proto";
// Network service is usesd to gain visibility into networks
service Network {
rpc ListNodes(ListRequest) returns (ListResponse) {};
rpc ListPeers(PeerRequest) returns (PeerResponse) {};
rpc Topology(TopologyRequest) returns (TopologyResponse) {};
rpc ListRoutes(go.micro.router.Request) returns (go.micro.router.ListResponse) {};
}
// Empty request
message ListRequest {}
// ListResponse is returned by ListNodes
message ListResponse {
// network nodes
repeated Node nodes = 1;
}
// PeerRequest requests list of peers
message PeerRequest {
// node id
string id = 1;
// node topology depth
uint32 depth = 1;
}
// PeerResponse is returned by ListPeers
message PeerResponse {
repeated Node peers = 1;
}
// TopologyRequest list node topology
message TopologyRequest {
// node id
string id = 1;
}
// TopologyResponse is returned by Topology
message TopologyResponse {
Peer topology = 1;
// return peer topology
Peer peers = 1;
}
// Node is network node