frostfs-node/pkg/services/object/search/search.go
Dmitrii Stepanov 7429553266
[#1437] node: Fix contextcheck linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-11-13 10:36:10 +03:00

45 lines
917 B
Go

package searchsvc
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"go.uber.org/zap"
)
// Search serves a request to select the objects.
func (s *Service) Search(ctx context.Context, prm Prm) error {
exec := &execCtx{
svc: s,
prm: prm,
}
exec.setLogger(s.log)
return exec.execute(ctx)
}
func (exec *execCtx) execute(ctx context.Context) error {
exec.log.Debug(ctx, logs.ServingRequest)
err := exec.executeLocal(ctx)
exec.logResult(ctx, err)
if exec.isLocal() {
exec.log.Debug(ctx, logs.SearchReturnResultDirectly)
return err
}
err = exec.executeOnContainer(ctx)
exec.logResult(ctx, err)
return err
}
func (exec *execCtx) logResult(ctx context.Context, err error) {
switch {
default:
exec.log.Debug(ctx, logs.OperationFinishedWithError, zap.String("error", err.Error()))
case err == nil:
exec.log.Debug(ctx, logs.OperationFinishedSuccessfully)
}
}