From 0dbea5452ad686d8d1f38c97116200324492ab70 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 24 Mar 2022 15:42:49 +0300 Subject: [PATCH] [#180] pool: add WaitForContainerRemoved Signed-off-by: Denis Kirillov --- pool/pool.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pool/pool.go b/pool/pool.go index ac36df4..203d405 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -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. func waitFor(ctx context.Context, params *WaitParams, condition func(context.Context) bool) error { wctx, cancel := context.WithTimeout(ctx, params.timeout)