[#180] pool: add WaitForContainerRemoved

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-24 15:42:49 +03:00 committed by Alex Vanin
parent 47345a33da
commit 0dbea5452a

View file

@ -1540,6 +1540,19 @@ func WaitForEACLPresence(ctx context.Context, pool *Pool, cnrID *cid.ID, table *
}) })
} }
// WaitForContainerRemoved waits until the container is removed from the NeoFS network.
func WaitForContainerRemoved(ctx context.Context, pool *Pool, cnrID *cid.ID, waitParams *WaitParams) error {
var prm PrmContainerGet
if cnrID != nil {
prm.SetContainerID(*cnrID)
}
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
_, err := pool.GetContainer(ctx, prm)
return sdkClient.IsErrContainerNotFound(err)
})
}
// waitFor await that given condition will be met in waitParams time. // waitFor await that given condition will be met in waitParams time.
func waitFor(ctx context.Context, params *WaitParams, condition func(context.Context) bool) error { func waitFor(ctx context.Context, params *WaitParams, condition func(context.Context) bool) error {
wctx, cancel := context.WithTimeout(ctx, params.timeout) wctx, cancel := context.WithTimeout(ctx, params.timeout)