forked from TrueCloudLab/frostfs-sdk-go
[#48] client: Refactor ContainerDelete()
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
09ed2863fc
commit
8bc8f1f365
1 changed files with 10 additions and 17 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
|
||||
"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"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
||||
frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
|
||||
|
@ -71,7 +72,7 @@ func (x *PrmContainerDelete) formRequest(c *Client) (*v2container.DeleteRequest,
|
|||
|
||||
var req v2container.DeleteRequest
|
||||
req.SetBody(reqBody)
|
||||
req.SetMetaHeader(&meta)
|
||||
c.prepareRequest(&req, &meta)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
|
@ -118,24 +119,16 @@ func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// init call context
|
||||
|
||||
var (
|
||||
cc contextCall
|
||||
res ResContainerDelete
|
||||
)
|
||||
|
||||
c.initCallContext(&cc)
|
||||
cc.req = req
|
||||
cc.statusRes = &res
|
||||
cc.call = func() (responseV2, error) {
|
||||
return rpcapi.DeleteContainer(&c.c, req, client.WithContext(ctx))
|
||||
if err := signature.SignServiceMessage(&c.prm.key, req); err != nil {
|
||||
return nil, fmt.Errorf("sign request: %w", err)
|
||||
}
|
||||
|
||||
// process call
|
||||
if !cc.processCall() {
|
||||
return nil, cc.err
|
||||
resp, err := rpcapi.DeleteContainer(&c.c, req, client.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
var res ResContainerDelete
|
||||
res.st, err = c.processResponse(resp)
|
||||
return &res, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue