2023-04-07 11:21:05 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) Doctor(ctx context.Context, req *control.DoctorRequest) (*control.DoctorResponse, error) {
|
|
|
|
err := s.isValidRequest(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
|
|
}
|
|
|
|
|
2023-12-11 10:18:34 +00:00
|
|
|
if !req.GetBody().GetRemoveDuplicates() {
|
2023-04-07 11:21:05 +00:00
|
|
|
return nil, status.Error(codes.InvalidArgument, "operation not specified")
|
|
|
|
}
|
|
|
|
|
|
|
|
var prm engine.RemoveDuplicatesPrm
|
2023-12-11 10:18:34 +00:00
|
|
|
prm.Concurrency = int(req.GetBody().GetConcurrency())
|
2023-04-07 11:21:05 +00:00
|
|
|
|
|
|
|
err = s.s.RemoveDuplicates(ctx, prm)
|
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
resp := &control.DoctorResponse{Body: &control.DoctorResponse_Body{}}
|
|
|
|
|
|
|
|
err = SignMessage(s.key, resp)
|
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
return resp, nil
|
|
|
|
}
|