forked from TrueCloudLab/frostfs-node
[#444] reputation/grpc: Implement gRPC ReputationServiceServer
Implement gRPC ReputationServiceServer on structure that forwards requests to underlying NeoFS API v2 ReputationService `Server`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
df97e35f30
commit
b37b608150
1 changed files with 37 additions and 0 deletions
37
pkg/network/transport/reputation/grpc/service.go
Normal file
37
pkg/network/transport/reputation/grpc/service.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package grpcreputation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/reputation"
|
||||||
|
reputation2 "github.com/nspcc-dev/neofs-api-go/v2/reputation/grpc"
|
||||||
|
reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server wraps NeoFS API v2 Container service server
|
||||||
|
// and provides gRPC Container service server interface.
|
||||||
|
type Server struct {
|
||||||
|
srv reputationrpc.Server
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates, initializes and returns Server instance.
|
||||||
|
func New(srv reputationrpc.Server) *Server {
|
||||||
|
return &Server{
|
||||||
|
srv: srv,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) SendLocalTrust(ctx context.Context, r *reputation2.SendLocalTrustRequest) (*reputation2.SendLocalTrustResponse, error) {
|
||||||
|
req := new(reputation.SendLocalTrustRequest)
|
||||||
|
if err := req.FromGRPCMessage(r); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.srv.SendLocalTrust(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
// TODO: think about how we transport errors through gRPC
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.ToGRPCMessage().(*reputation2.SendLocalTrustResponse), nil
|
||||||
|
}
|
Loading…
Reference in a new issue