forked from TrueCloudLab/frostfs-node
Dmitrii Stepanov
0b38419fbf
Resolve containedctx and contextcheck linters. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
49 lines
868 B
Go
49 lines
868 B
Go
package searchsvc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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.prepare()
|
|
|
|
exec.setLogger(s.log)
|
|
|
|
exec.execute(ctx)
|
|
|
|
return exec.statusError.err
|
|
}
|
|
|
|
func (exec *execCtx) execute(ctx context.Context) {
|
|
exec.log.Debug("serving request...")
|
|
|
|
// perform local operation
|
|
exec.executeLocal()
|
|
|
|
exec.analyzeStatus(ctx, true)
|
|
}
|
|
|
|
func (exec *execCtx) analyzeStatus(ctx context.Context, execCnr bool) {
|
|
// analyze local result
|
|
switch exec.status {
|
|
default:
|
|
exec.log.Debug("operation finished with error",
|
|
zap.String("error", exec.err.Error()),
|
|
)
|
|
case statusOK:
|
|
exec.log.Debug("operation finished successfully")
|
|
}
|
|
|
|
if execCnr {
|
|
exec.executeOnContainer(ctx)
|
|
exec.analyzeStatus(ctx, false)
|
|
}
|
|
}
|