forked from TrueCloudLab/frostfs-node
[#839] service/object: Add high level functions to control request forwarding
Applicable for object/get execution context. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b3464e8140
commit
b97cdbea9e
3 changed files with 17 additions and 6 deletions
|
@ -12,11 +12,10 @@ func (exec *execCtx) assemble() {
|
|||
return
|
||||
}
|
||||
|
||||
// do not use forwarding during assembly stage
|
||||
// assembly flag is not inherited in produced
|
||||
// `execCtx`, however `commonPrm` does, so it
|
||||
// makes sense to nil it there
|
||||
exec.prm.SetRequestForwarder(nil)
|
||||
// Do not use forwarding during assembly stage.
|
||||
// Request forwarding closure inherited in produced
|
||||
// `execCtx` so it should be disabled there.
|
||||
exec.disableForwarding()
|
||||
|
||||
exec.log.Debug("trying to assemble the object...")
|
||||
|
||||
|
|
|
@ -347,3 +347,15 @@ func (exec *execCtx) writeCollectedObject() {
|
|||
exec.writeObjectPayload(exec.collectedObject)
|
||||
}
|
||||
}
|
||||
|
||||
// isForwardingEnabled returns true if common execution
|
||||
// parameters has request forwarding closure set.
|
||||
func (exec execCtx) isForwardingEnabled() bool {
|
||||
return exec.prm.forwarder != nil
|
||||
}
|
||||
|
||||
// disableForwarding removes request forwarding closure from common
|
||||
// parameters, so it won't be inherited in new execution contexts.
|
||||
func (exec *execCtx) disableForwarding() {
|
||||
exec.prm.SetRequestForwarder(nil)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ func (c *clientCacheWrapper) get(addr network.AddressGroup) (getClient, error) {
|
|||
}
|
||||
|
||||
func (c *clientWrapper) getObject(exec *execCtx, addr network.AddressGroup) (*objectSDK.Object, error) {
|
||||
if exec.prm.forwarder != nil {
|
||||
if exec.isForwardingEnabled() {
|
||||
return exec.prm.forwarder(addr, c.client)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue