forked from TrueCloudLab/frostfs-node
[#277] getsvc: Rename and reorder code
Rename execCtx to request. Move code to appropriate files. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
1440450606
commit
45438e7b06
15 changed files with 442 additions and 445 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (exec *execCtx) executeLocal(ctx context.Context) {
|
||||
func (r *request) executeLocal(ctx context.Context) {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "getService.executeLocal")
|
||||
defer func() {
|
||||
span.End()
|
||||
|
@ -19,7 +19,7 @@ func (exec *execCtx) executeLocal(ctx context.Context) {
|
|||
|
||||
var err error
|
||||
|
||||
exec.collectedObject, err = exec.get(ctx)
|
||||
r.collectedObject, err = r.get(ctx)
|
||||
|
||||
var errSplitInfo *objectSDK.SplitInfoError
|
||||
var errRemoved apistatus.ObjectAlreadyRemoved
|
||||
|
@ -27,35 +27,35 @@ func (exec *execCtx) executeLocal(ctx context.Context) {
|
|||
|
||||
switch {
|
||||
default:
|
||||
exec.status = statusUndefined
|
||||
exec.err = err
|
||||
r.status = statusUndefined
|
||||
r.err = err
|
||||
|
||||
exec.log.Debug(logs.GetLocalGetFailed,
|
||||
r.log.Debug(logs.GetLocalGetFailed,
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
case err == nil:
|
||||
exec.status = statusOK
|
||||
exec.err = nil
|
||||
exec.writeCollectedObject(ctx)
|
||||
r.status = statusOK
|
||||
r.err = nil
|
||||
r.writeCollectedObject(ctx)
|
||||
case errors.As(err, &errRemoved):
|
||||
exec.status = statusINHUMED
|
||||
exec.err = errRemoved
|
||||
r.status = statusINHUMED
|
||||
r.err = errRemoved
|
||||
case errors.As(err, &errSplitInfo):
|
||||
exec.status = statusVIRTUAL
|
||||
mergeSplitInfo(exec.splitInfo(), errSplitInfo.SplitInfo())
|
||||
exec.err = objectSDK.NewSplitInfoError(exec.infoSplit)
|
||||
r.status = statusVIRTUAL
|
||||
mergeSplitInfo(r.splitInfo(), errSplitInfo.SplitInfo())
|
||||
r.err = objectSDK.NewSplitInfoError(r.infoSplit)
|
||||
case errors.As(err, &errOutOfRange):
|
||||
exec.status = statusOutOfRange
|
||||
exec.err = errOutOfRange
|
||||
r.status = statusOutOfRange
|
||||
r.err = errOutOfRange
|
||||
}
|
||||
}
|
||||
|
||||
func (exec *execCtx) get(ctx context.Context) (*objectSDK.Object, error) {
|
||||
if exec.headOnly() {
|
||||
return exec.localStorage.Head(ctx, exec.address(), exec.isRaw())
|
||||
func (r *request) get(ctx context.Context) (*objectSDK.Object, error) {
|
||||
if r.headOnly() {
|
||||
return r.localStorage.Head(ctx, r.address(), r.isRaw())
|
||||
}
|
||||
if rng := exec.ctxRange(); rng != nil {
|
||||
return exec.localStorage.Range(ctx, exec.address(), rng)
|
||||
if rng := r.ctxRange(); rng != nil {
|
||||
return r.localStorage.Range(ctx, r.address(), rng)
|
||||
}
|
||||
return exec.localStorage.Get(ctx, exec.address())
|
||||
return r.localStorage.Get(ctx, r.address())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue