[#48] client: Refactor ContainerAnnounceUsedSpace()
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
6c9b92c9dc
commit
b2c66cb99e
1 changed files with 12 additions and 17 deletions
|
@ -2,10 +2,13 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
v2container "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container"
|
v2container "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container"
|
||||||
rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
|
rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
|
v2session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/signature"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@ func (x *PrmAnnounceSpace) formRequest(c *Client) (*v2container.AnnounceUsedSpac
|
||||||
|
|
||||||
var req v2container.AnnounceUsedSpaceRequest
|
var req v2container.AnnounceUsedSpaceRequest
|
||||||
req.SetBody(reqBody)
|
req.SetBody(reqBody)
|
||||||
|
c.prepareRequest(&req, new(v2session.RequestMetaHeader))
|
||||||
return &req, nil
|
return &req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,25 +75,16 @@ func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounce
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// init call context
|
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
||||||
|
return nil, fmt.Errorf("sign request: %w", err)
|
||||||
var (
|
|
||||||
cc contextCall
|
|
||||||
res ResAnnounceSpace
|
|
||||||
)
|
|
||||||
|
|
||||||
c.initCallContext(&cc)
|
|
||||||
cc.meta = prm.prmCommonMeta
|
|
||||||
cc.req = req
|
|
||||||
cc.statusRes = &res
|
|
||||||
cc.call = func() (responseV2, error) {
|
|
||||||
return rpcapi.AnnounceUsedSpace(&c.c, req, client.WithContext(ctx))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// process call
|
resp, err := rpcapi.AnnounceUsedSpace(&c.c, req, client.WithContext(ctx))
|
||||||
if !cc.processCall() {
|
if err != nil {
|
||||||
return nil, cc.err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &res, nil
|
var res ResAnnounceSpace
|
||||||
|
res.st, err = c.processResponse(resp)
|
||||||
|
return &res, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue