Skip to content

Commit

Permalink
Re-Add WaitAllStoppedTimeout using WaitAllStopped, but deprecate it
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Kniggebrot authored Oct 25, 2024
1 parent 246f63b commit 4d1d7b0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,20 @@ func (c *Container) WaitAllStopped(ctx context.Context) {
}
}

// WaitAllStoppedTimeout waits x seconds or until all services are stopped. Services might still run after the call! Call Container.StopAll() to stop them.
// 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.
func (c *Container) WaitAllStoppedTimeout(timeout time.Duration) {
var ctx context.Context
var cancel context.CancelFunc
if timeout != 0 {
ctx, cancel = context.WithTimeout(context.Background(), timeout)
} else {
ctx, cancel = context.WithCancel(context.Background())
}
defer cancel()
return c.WaitAllStopped(ctx)

Check failure on line 360 in service.go

View workflow job for this annotation

GitHub Actions / build

c.WaitAllStopped(ctx) (no value) used as value
}

// ServiceErrors returns all errors occurred in services
func (c *Container) ServiceErrors() map[string]error {
errs := map[string]error{}
Expand Down

0 comments on commit 4d1d7b0

Please sign in to comment.