forked from TrueCloudLab/frostfs-node
[#223] sg: Refactor storage group parameters
Resolve containedctx linter for SearchSGPrm and GetSGPrm structs. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
6016d78a45
commit
ae86cda58c
3 changed files with 8 additions and 16 deletions
|
@ -11,10 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchSGPrm groups the parameters which are formed by Processor to search the storage group objects.
|
// SearchSGPrm groups the parameters which are formed by Processor to search the storage group objects.
|
||||||
// nolint: containedctx
|
|
||||||
type SearchSGPrm struct {
|
type SearchSGPrm struct {
|
||||||
Context context.Context
|
|
||||||
|
|
||||||
Container cid.ID
|
Container cid.ID
|
||||||
|
|
||||||
NodeInfo client.NodeInfo
|
NodeInfo client.NodeInfo
|
||||||
|
@ -26,10 +23,7 @@ type SearchSGDst struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSGPrm groups parameter of GetSG operation.
|
// GetSGPrm groups parameter of GetSG operation.
|
||||||
// nolint: containedctx
|
|
||||||
type GetSGPrm struct {
|
type GetSGPrm struct {
|
||||||
Context context.Context
|
|
||||||
|
|
||||||
OID oid.ID
|
OID oid.ID
|
||||||
CID cid.ID
|
CID cid.ID
|
||||||
|
|
||||||
|
@ -42,11 +36,11 @@ type SGSource interface {
|
||||||
// ListSG must list storage group objects in the container. Formed list must be written to destination.
|
// ListSG must list storage group objects in the container. Formed list must be written to destination.
|
||||||
//
|
//
|
||||||
// Must return any error encountered which did not allow to form the list.
|
// Must return any error encountered which did not allow to form the list.
|
||||||
ListSG(*SearchSGDst, SearchSGPrm) error
|
ListSG(context.Context, *SearchSGDst, SearchSGPrm) error
|
||||||
|
|
||||||
// GetSG must return storage group object for the provided CID, OID,
|
// GetSG must return storage group object for the provided CID, OID,
|
||||||
// container and netmap state.
|
// container and netmap state.
|
||||||
GetSG(GetSGPrm) (*storagegroup.StorageGroup, error)
|
GetSG(context.Context, GetSGPrm) (*storagegroup.StorageGroup, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageGroup combines storage group object ID and its structure.
|
// StorageGroup combines storage group object ID and its structure.
|
||||||
|
|
|
@ -153,12 +153,11 @@ func (ap *Processor) findStorageGroups(cnr cid.ID, shuffled netmapcore.Nodes) []
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), ap.searchTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), ap.searchTimeout)
|
||||||
|
|
||||||
prm.Context = ctx
|
|
||||||
prm.NodeInfo = info
|
prm.NodeInfo = info
|
||||||
|
|
||||||
var dst storagegroup.SearchSGDst
|
var dst storagegroup.SearchSGDst
|
||||||
|
|
||||||
err = ap.sgSrc.ListSG(&dst, prm)
|
err = ap.sgSrc.ListSG(ctx, &dst, prm)
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
@ -189,9 +188,8 @@ func (ap *Processor) filterExpiredSG(cid cid.ID, sgIDs []oid.ID,
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), ap.searchTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), ap.searchTimeout)
|
||||||
|
|
||||||
getSGPrm.OID = sgID
|
getSGPrm.OID = sgID
|
||||||
getSGPrm.Context = ctx
|
|
||||||
|
|
||||||
sg, err := ap.sgSrc.GetSG(getSGPrm)
|
sg, err := ap.sgSrc.GetSG(ctx, getSGPrm)
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ func (c *ClientCache) Get(info clientcore.NodeInfo) (clientcore.Client, error) {
|
||||||
// Returns storage groups structure from received object.
|
// Returns storage groups structure from received object.
|
||||||
//
|
//
|
||||||
// Returns an error of type apistatus.ObjectNotFound if storage group is missing.
|
// Returns an error of type apistatus.ObjectNotFound if storage group is missing.
|
||||||
func (c *ClientCache) GetSG(prm storagegroup2.GetSGPrm) (*storagegroup.StorageGroup, error) {
|
func (c *ClientCache) GetSG(ctx context.Context, prm storagegroup2.GetSGPrm) (*storagegroup.StorageGroup, error) {
|
||||||
var sgAddress oid.Address
|
var sgAddress oid.Address
|
||||||
sgAddress.SetContainer(prm.CID)
|
sgAddress.SetContainer(prm.CID)
|
||||||
sgAddress.SetObject(prm.OID)
|
sgAddress.SetObject(prm.OID)
|
||||||
|
|
||||||
return c.getSG(prm.Context, sgAddress, &prm.NetMap, prm.Container)
|
return c.getSG(ctx, sgAddress, &prm.NetMap, prm.Container)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.NetMap, cn [][]netmap.NodeInfo) (*storagegroup.StorageGroup, error) {
|
func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.NetMap, cn [][]netmap.NodeInfo) (*storagegroup.StorageGroup, error) {
|
||||||
|
@ -214,7 +214,7 @@ func (c *ClientCache) getWrappedClient(info clientcore.NodeInfo) (frostfsapiclie
|
||||||
return cInternal, nil
|
return cInternal, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ClientCache) ListSG(dst *storagegroup2.SearchSGDst, prm storagegroup2.SearchSGPrm) error {
|
func (c ClientCache) ListSG(ctx context.Context, dst *storagegroup2.SearchSGDst, prm storagegroup2.SearchSGPrm) error {
|
||||||
cli, err := c.getWrappedClient(prm.NodeInfo)
|
cli, err := c.getWrappedClient(prm.NodeInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not get API client from cache")
|
return fmt.Errorf("could not get API client from cache")
|
||||||
|
@ -224,7 +224,7 @@ func (c ClientCache) ListSG(dst *storagegroup2.SearchSGDst, prm storagegroup2.Se
|
||||||
|
|
||||||
cliPrm.SetContainerID(prm.Container)
|
cliPrm.SetContainerID(prm.Container)
|
||||||
|
|
||||||
res, err := cli.SearchSG(prm.Context, cliPrm)
|
res, err := cli.SearchSG(ctx, cliPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue