5d0816430f
* rename pkg/linksharing to linksharing * rename pkg/httpserver to linksharing/httpserver * rename pkg/eestream to uplink/eestream * rename pkg/stream to uplink/stream * rename pkg/metainfo/kvmetainfo to uplink/metainfo/kvmetainfo * rename pkg/auth/signing to pkg/signing * rename pkg/storage to uplink/storage * rename pkg/accounting to satellite/accounting * rename pkg/audit to satellite/audit * rename pkg/certdb to satellite/certdb * rename pkg/discovery to satellite/discovery * rename pkg/overlay to satellite/overlay * rename pkg/datarepair to satellite/repair
42 lines
1009 B
Go
42 lines
1009 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package irreparable
|
|
|
|
import (
|
|
"context"
|
|
|
|
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
|
|
|
"storj.io/storj/pkg/pb"
|
|
)
|
|
|
|
var (
|
|
mon = monkit.Package()
|
|
)
|
|
|
|
// Inspector is a gRPC service for inspecting irreparable internals
|
|
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
|
|
}
|