forked from TrueCloudLab/frostfs-node
71b87155ef
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
35 lines
826 B
Go
35 lines
826 B
Go
package accounting
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
|
)
|
|
|
|
type ServiceExecutor interface {
|
|
Balance(context.Context, *accounting.BalanceRequestBody) (*accounting.BalanceResponseBody, error)
|
|
}
|
|
|
|
type executorSvc struct {
|
|
exec ServiceExecutor
|
|
}
|
|
|
|
// NewExecutionService wraps ServiceExecutor and returns Accounting Service interface.
|
|
func NewExecutionService(exec ServiceExecutor) Server {
|
|
return &executorSvc{
|
|
exec: exec,
|
|
}
|
|
}
|
|
|
|
func (s *executorSvc) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) {
|
|
respBody, err := s.exec.Balance(ctx, req.GetBody())
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not execute Balance request: %w", err)
|
|
}
|
|
|
|
resp := new(accounting.BalanceResponse)
|
|
resp.SetBody(respBody)
|
|
|
|
return resp, nil
|
|
}
|