Skip to content

Commit

Permalink
cli: Replace looped time.Sleep with time.Timer
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jun 16, 2023
1 parent c3259a2 commit 8cebfb4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions cmd/neofs-cli/modules/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ It will be stored in sidechain when inner ring will accepts it.`,
getPrm.SetClient(cli)
getPrm.SetContainer(id)

for {
time.Sleep(1 * time.Second)
const waitInterval = time.Second

t := time.NewTimer(waitInterval)
defer t.Stop()

for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
common.ExitOnErr(cmd, "", errCreateTimeout)
default:
case <-t.C:
}

_, err := internalclient.GetContainer(ctx, getPrm)
Expand Down
9 changes: 6 additions & 3 deletions cmd/neofs-cli/modules/container/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ Only owner of the container has a permission to remove container.`,
getPrm.SetClient(cli)
getPrm.SetContainer(id)

for {
time.Sleep(1 * time.Second)
const waitInterval = time.Second

t := time.NewTimer(waitInterval)
defer t.Stop()

for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
common.ExitOnErr(cmd, "", errDeleteTimeout)
default:
case <-t.C:
}

_, err := internalclient.GetContainer(ctx, getPrm)
Expand Down
9 changes: 6 additions & 3 deletions cmd/neofs-cli/modules/container/set_eacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
getEACLPrm.SetClient(cli)
getEACLPrm.SetContainer(id)

for {
time.Sleep(1 * time.Second)
const waitInterval = time.Second

t := time.NewTimer(waitInterval)
defer t.Stop()

for ; ; t.Reset(waitInterval) {
select {
case <-ctx.Done():
common.ExitOnErr(cmd, "", errSetEACLTimeout)
default:
case <-t.C:
}

res, err := internalclient.EACL(ctx, getEACLPrm)
Expand Down

0 comments on commit 8cebfb4

Please sign in to comment.