2021-03-24 09:55:07 +00:00
|
|
|
package reputationrpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
|
2021-03-24 09:55:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type responseService struct {
|
|
|
|
respSvc *response.Service
|
|
|
|
|
|
|
|
svc Server
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewResponseService returns reputation service server instance that passes
|
|
|
|
// internal service call to response service.
|
|
|
|
func NewResponseService(cnrSvc Server, respSvc *response.Service) Server {
|
|
|
|
return &responseService{
|
|
|
|
respSvc: respSvc,
|
|
|
|
svc: cnrSvc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
|
2021-03-24 09:55:07 +00:00
|
|
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2021-05-07 11:13:11 +00:00
|
|
|
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
|
2021-03-24 09:55:07 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
return resp.(*reputation.AnnounceLocalTrustResponse), nil
|
2021-03-24 09:55:07 +00:00
|
|
|
}
|
2021-04-05 09:27:58 +00:00
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
func (s *responseService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
|
2021-04-05 09:27:58 +00:00
|
|
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2021-05-07 11:13:11 +00:00
|
|
|
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
|
2021-04-05 09:27:58 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
|
2021-04-05 09:27:58 +00:00
|
|
|
}
|