Skip to content

Commit 4d1d7b0

Browse files
authored
Re-Add WaitAllStoppedTimeout using WaitAllStopped, but deprecate it
Re-add `WaitAllStoppedTimeout()` to avoid breaking code using it, but deprecate it to signal that `WaitAllStopped()` should be used instead. It is re-implemented via `WaitAllStopped()`; we can/will remove `WaitAllStoppedTimeout()` in the next major release
1 parent 246f63b commit 4d1d7b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

service.go

+14
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,20 @@ func (c *Container) WaitAllStopped(ctx context.Context) {
346346
}
347347
}
348348

349+
// WaitAllStoppedTimeout waits x seconds or until all services are stopped. Services might still run after the call! Call Container.StopAll() to stop them.
350+
// Deprecated: WaitAllStopped is the preferred method of Waiting for all stopped containers, it can take a context with a deadline/timeout for the same functionality.
351+
func (c *Container) WaitAllStoppedTimeout(timeout time.Duration) {
352+
var ctx context.Context
353+
var cancel context.CancelFunc
354+
if timeout != 0 {
355+
ctx, cancel = context.WithTimeout(context.Background(), timeout)
356+
} else {
357+
ctx, cancel = context.WithCancel(context.Background())
358+
}
359+
defer cancel()
360+
return c.WaitAllStopped(ctx)
361+
}
362+
349363
// ServiceErrors returns all errors occurred in services
350364
func (c *Container) ServiceErrors() map[string]error {
351365
errs := map[string]error{}

0 commit comments

Comments
 (0)