Skip to content

[Enhancement]: Transition Wait from WithStartupTimeout to context timeoutΒ #3065

@james-async

Description

@james-async

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.

// 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions