storj/satellite/repair/irreparable/inspector.go
Egon Elbre 080ba47a06 all: fix dots
Change-Id: I6a419c62700c568254ff67ae5b73efed2fc98aa2
2020-07-16 14:58:28 +00:00

44 lines
1.0 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package irreparable
import (
"context"
"github.com/spacemonkeygo/monkit/v3"
"storj.io/common/pb"
)
var (
mon = monkit.Package()
)
// Inspector is a RPC service for inspecting irreparable internals
//
// architecture: Endpoint
type Inspector struct {
irrdb DB
}
// NewInspector creates an Inspector.
func NewInspector(irrdb DB) *Inspector {
return &Inspector{irrdb: irrdb}
}
// ListIrreparableSegments returns a number of irreparable segments by limit and offset.
func (srv *Inspector) ListIrreparableSegments(ctx context.Context, req *pb.ListIrreparableSegmentsRequest) (_ *pb.ListIrreparableSegmentsResponse, err error) {
defer mon.Task()(&ctx)(&err)
last := req.GetLastSeenSegmentPath()
if len(req.GetLastSeenSegmentPath()) == 0 {
last = []byte{}
}
segments, err := srv.irrdb.GetLimited(ctx, int(req.GetLimit()), last)
if err != nil {
return nil, err
}
return &pb.ListIrreparableSegmentsResponse{Segments: segments}, err
}