-
-
Notifications
You must be signed in to change notification settings - Fork 588
Description
Proposal
The current structure of the wait implementation relies upon a default timeout, or the user setting a specific timeout via the WithStartupTimeout method.
It has been noted that this approach is not very "go-like". With go we can rely upon the context to control the timeout. The Run method already takes a context. It is natural for go programs to control timeout periods with context timeout.
testcontainers-go/modules/elasticsearch/elasticsearch.go
Lines 44 to 45 in 16b0741
| // Run creates an instance of the Elasticsearch container type | |
| func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*ElasticsearchContainer, error) { |
This issue would Deprecate the use of "startupTimeout" in favor of the user passing a context with the desired timeout. Thus the existing WithStartupTimeout would continue to work as is currently supported. The main change would focus around the use of a default timeout. If the context deadline (ctx.Deadline()) returns true, use that context, otherwise fallback to the previous behavior.
This would supersede issue #2982, due to the conversation on that PR (#2983).