2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2019-01-14 18:47:22 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package overlay
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2019-02-28 19:55:27 +00:00
|
|
|
"github.com/zeebo/errs"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/pb"
|
2019-01-14 18:47:22 +00:00
|
|
|
)
|
|
|
|
|
2020-05-11 06:26:32 +01:00
|
|
|
// Inspector is a RPC service for inspecting overlay internals
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Endpoint
|
2019-01-14 18:47:22 +00:00
|
|
|
type Inspector struct {
|
2019-08-06 17:35:59 +01:00
|
|
|
service *Service
|
2019-01-14 18:47:22 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// NewInspector creates an Inspector.
|
2019-08-06 17:35:59 +01:00
|
|
|
func NewInspector(service *Service) *Inspector {
|
|
|
|
return &Inspector{service: service}
|
2019-01-14 18:47:22 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 17:35:59 +01:00
|
|
|
// CountNodes returns the number of nodes in the overlay.
|
2019-06-04 12:36:27 +01:00
|
|
|
func (srv *Inspector) CountNodes(ctx context.Context, req *pb.CountNodesRequest) (_ *pb.CountNodesResponse, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
2019-08-06 17:35:59 +01:00
|
|
|
overlayKeys, err := srv.service.Inspect(ctx)
|
2019-01-14 18:47:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &pb.CountNodesResponse{
|
|
|
|
Count: int64(len(overlayKeys)),
|
|
|
|
}, nil
|
|
|
|
}
|
2019-02-28 19:55:27 +00:00
|
|
|
|
2019-08-06 17:35:59 +01:00
|
|
|
// DumpNodes returns all of the nodes in the overlay.
|
2019-06-04 12:36:27 +01:00
|
|
|
func (srv *Inspector) DumpNodes(ctx context.Context, req *pb.DumpNodesRequest) (_ *pb.DumpNodesResponse, err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
2019-02-28 19:55:27 +00:00
|
|
|
return &pb.DumpNodesResponse{}, errs.New("Not Implemented")
|
|
|
|
}
|