mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 13:41:47 +00:00
cli: add retry to all requests to NeoFS in upload-bin
Add retry to `NetworkInfo` and `uploadObj`. Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
8b43c33e44
commit
42c8e40eaa
1 changed files with 11 additions and 2 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
|
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/pool"
|
"github.com/nspcc-dev/neofs-sdk-go/pool"
|
||||||
|
@ -99,7 +100,13 @@ func uploadBin(ctx *cli.Context) error {
|
||||||
return cli.Exit(fmt.Sprintf("failed to dial NeoFS pool: %v", err), 1)
|
return cli.Exit(fmt.Sprintf("failed to dial NeoFS pool: %v", err), 1)
|
||||||
}
|
}
|
||||||
defer p.Close()
|
defer p.Close()
|
||||||
net, err := p.NetworkInfo(ctx.Context, client.PrmNetworkInfo{})
|
|
||||||
|
var net netmap.NetworkInfo
|
||||||
|
err = retry(func() error {
|
||||||
|
var errNet error
|
||||||
|
net, errNet = p.NetworkInfo(ctx.Context, client.PrmNetworkInfo{})
|
||||||
|
return errNet
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.Exit(fmt.Errorf("failed to get network info: %w", err), 1)
|
return cli.Exit(fmt.Errorf("failed to get network info: %w", err), 1)
|
||||||
}
|
}
|
||||||
|
@ -423,7 +430,9 @@ func updateIndexFiles(ctx *cli.Context, p *pool.Pool, containerID cid.ID, accoun
|
||||||
*object.NewAttribute(attributeKey, strconv.Itoa(int(i))),
|
*object.NewAttribute(attributeKey, strconv.Itoa(int(i))),
|
||||||
*object.NewAttribute("IndexSize", strconv.Itoa(int(indexFileSize))),
|
*object.NewAttribute("IndexSize", strconv.Itoa(int(indexFileSize))),
|
||||||
}
|
}
|
||||||
err := uploadObj(ctx.Context, p, signer, account.PrivateKey().GetScriptHash(), containerID, buffer, attrs, homomorphicHashingDisabled)
|
err := retry(func() error {
|
||||||
|
return uploadObj(ctx.Context, p, signer, account.PrivateKey().GetScriptHash(), containerID, buffer, attrs, homomorphicHashingDisabled)
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to upload index file %d: %w", i, err)
|
return fmt.Errorf("failed to upload index file %d: %w", i, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue