87925789de
now kad inspector features exist on every server that has kademlia running. likewise, overlay and statdb. this means kad inspection features are now available on storage nodes Change-Id: I343c873552341de13302bfb7a5d79cccc84fc6b8
33 lines
704 B
Go
33 lines
704 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package overlay
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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
|
|
}
|