storj/pkg/overlay/inspector.go
Dylan Lott bacd683879
Adds DumpNodes method to Kademlia Inspector (#1328)
* Wiring up DumpNodes response for Inspector

* Finalize everything and test that it works

* remove changes to overlay inspector

* Replace list with iterate method in DumpNodes

* generate proto

* Merge in nodeinfo changes

* Update iterate function in DumpNodes

* Fix import order
2019-02-28 12:55:27 -07:00

40 lines
966 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package overlay
import (
"context"
"github.com/zeebo/errs"
"storj.io/storj/pkg/pb"
)
// Inspector is a gRPC service for inspecting overlay cache internals
type Inspector struct {
cache *Cache
}
// NewInspector creates an Inspector
func NewInspector(cache *Cache) *Inspector {
return &Inspector{cache: cache}
}
// CountNodes returns the number of nodes in the cache
func (srv *Inspector) CountNodes(ctx context.Context, req *pb.CountNodesRequest) (*pb.CountNodesResponse, error) {
overlayKeys, err := srv.cache.Inspect(ctx)
if err != nil {
return nil, err
}
return &pb.CountNodesResponse{
Count: int64(len(overlayKeys)),
}, nil
}
// DumpNodes returns all of the nodes in the overlay cachea
func (srv *Inspector) DumpNodes(ctx context.Context, req *pb.DumpNodesRequest) (*pb.DumpNodesResponse, error) {
return &pb.DumpNodesResponse{}, errs.New("Not Implemented")
}