frostfs-node/pkg/services/accounting/executor.go
Leonard Lyubich 19f9c7eacb [#83] services: Remove setting of meta header from executing services
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-10-23 10:54:48 +03:00

35 lines
853 B
Go

package accounting
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
"github.com/pkg/errors"
)
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) accounting.Service {
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, errors.Wrap(err, "could not execute Balance request")
}
resp := new(accounting.BalanceResponse)
resp.SetBody(respBody)
return resp, nil
}