frostfs-node/pkg/services/session/executor.go
Evgenii Stratonikov 0e31c12e63 [#240] logs: Move log messages to constants
Drop duplicate entities.
Format entities.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-04-14 05:06:09 +00:00

46 lines
1.1 KiB
Go

package session
import (
"context"
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"go.uber.org/zap"
)
type ServiceExecutor interface {
Create(context.Context, *session.CreateRequestBody) (*session.CreateResponseBody, error)
}
type executorSvc struct {
exec ServiceExecutor
log *logger.Logger
}
// NewExecutionService wraps ServiceExecutor and returns Session Service interface.
func NewExecutionService(exec ServiceExecutor, l *logger.Logger) Server {
return &executorSvc{
exec: exec,
log: l,
}
}
func (s *executorSvc) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
s.log.Debug(logs.SessionServingRequest,
zap.String("component", "SessionService"),
zap.String("request", "Create"),
)
respBody, err := s.exec.Create(ctx, req.GetBody())
if err != nil {
return nil, fmt.Errorf("could not execute Create request: %w", err)
}
resp := new(session.CreateResponse)
resp.SetBody(respBody)
return resp, nil
}