forked from TrueCloudLab/frostfs-node
Airat Arifullin
9b13a18aac
* Update version within go.mod; * Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api instead. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
37 lines
1 KiB
Go
37 lines
1 KiB
Go
package accounting
|
|
|
|
import (
|
|
"context"
|
|
|
|
accountingsvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/accounting"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
|
|
accountingGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/grpc"
|
|
)
|
|
|
|
// Server wraps FrostFS API Accounting service and
|
|
// provides gRPC Accounting service server interface.
|
|
type Server struct {
|
|
srv accountingsvc.Server
|
|
}
|
|
|
|
// New creates, initializes and returns Server instance.
|
|
func New(c accountingsvc.Server) *Server {
|
|
return &Server{
|
|
srv: c,
|
|
}
|
|
}
|
|
|
|
// Balance converts gRPC BalanceRequest message and passes it to internal Accounting service.
|
|
func (s *Server) Balance(ctx context.Context, req *accountingGRPC.BalanceRequest) (*accountingGRPC.BalanceResponse, error) {
|
|
balReq := new(accounting.BalanceRequest)
|
|
if err := balReq.FromGRPCMessage(req); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
resp, err := s.srv.Balance(ctx, balReq)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp.ToGRPCMessage().(*accountingGRPC.BalanceResponse), nil
|
|
}
|