[#223] objectsvc: Refactor split-tree traverse
Resolve funlen & gocognit linters for traverseSplitChain method. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2ed9fd3f94
commit
93eba19a8e
1 changed files with 75 additions and 66 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
)
|
)
|
||||||
|
@ -72,7 +73,6 @@ func TraverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: funlen, gocognit
|
|
||||||
func traverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler) (bool, error) {
|
func traverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler) (bool, error) {
|
||||||
v, err := r.Head(addr)
|
v, err := r.Head(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -94,6 +94,14 @@ func traverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler)
|
||||||
default:
|
default:
|
||||||
return false, errors.New("lack of split information")
|
return false, errors.New("lack of split information")
|
||||||
case withLink:
|
case withLink:
|
||||||
|
return traverseByLink(cnr, link, r, h)
|
||||||
|
case withLast:
|
||||||
|
return traverseByLast(cnr, last, withLast, res, r, h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func traverseByLink(cnr cid.ID, link oid.ID, r HeadReceiver, h SplitMemberHandler) (bool, error) {
|
||||||
var addr oid.Address
|
var addr oid.Address
|
||||||
addr.SetContainer(cnr)
|
addr.SetContainer(cnr)
|
||||||
addr.SetObject(link)
|
addr.SetObject(link)
|
||||||
|
@ -136,7 +144,10 @@ func traverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case withLast:
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func traverseByLast(cnr cid.ID, last oid.ID, withLast bool, res *object.SplitInfo, r HeadReceiver, h SplitMemberHandler) (bool, error) {
|
||||||
var addr oid.Address
|
var addr oid.Address
|
||||||
addr.SetContainer(cnr)
|
addr.SetContainer(cnr)
|
||||||
|
|
||||||
|
@ -168,8 +179,6 @@ func traverseSplitChain(r HeadReceiver, addr oid.Address, h SplitMemberHandler)
|
||||||
last, withLast = directChain[len(directChain)-1].PreviousID()
|
last, withLast = directChain[len(directChain)-1].PreviousID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue