Documentation ¶
Overview ¶
Package wait provides strategies for checking if a container is ready.
Index ¶
- Constants
- type HealthCheckStrategy
- func (s *HealthCheckStrategy) WaitUntilReady(ctx context.Context, target wait.StrategyTarget) error
- func (s *HealthCheckStrategy) WithRetries(retries int) *HealthCheckStrategy
- func (s *HealthCheckStrategy) WithStartPeriod(duration time.Duration) *HealthCheckStrategy
- func (s *HealthCheckStrategy) WithTestInterval(interval time.Duration) *HealthCheckStrategy
- func (s *HealthCheckStrategy) WithTestTimeout(timeout time.Duration) *HealthCheckStrategy
- type HealthCheckTest
- type HealthCheckTestFunc
- type SleepStrategy
- type Strategy
- type StrategyTarget
Constants ¶
const ErrMaxRetriesExceeded healthCheckError = "max retries exceeded"
ErrMaxRetriesExceeded indicates that the number of max retries exceeded.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthCheckStrategy ¶
type HealthCheckStrategy struct {
// contains filtered or unexported fields
}
HealthCheckStrategy is a strategy for doing health check.
func ForHealthCheck ¶
func ForHealthCheck(f HealthCheckTestFunc) *HealthCheckStrategy
ForHealthCheck creates a new health check with default arguments.
func ForHealthCheckCmd ¶
func ForHealthCheckCmd(cmd string, args ...string) *HealthCheckStrategy
ForHealthCheckCmd checks by running a command in the container.
func (*HealthCheckStrategy) WaitUntilReady ¶
func (s *HealthCheckStrategy) WaitUntilReady(ctx context.Context, target wait.StrategyTarget) error
WaitUntilReady runs the health check test.
func (*HealthCheckStrategy) WithRetries ¶
func (s *HealthCheckStrategy) WithRetries(retries int) *HealthCheckStrategy
WithRetries sets a number of retries for running the test.
func (*HealthCheckStrategy) WithStartPeriod ¶
func (s *HealthCheckStrategy) WithStartPeriod(duration time.Duration) *HealthCheckStrategy
WithStartPeriod sets a period when retries are not counted. This is helpful when a container takes some time to spin up before it's ready for health checking.
func (*HealthCheckStrategy) WithTestInterval ¶
func (s *HealthCheckStrategy) WithTestInterval(interval time.Duration) *HealthCheckStrategy
WithTestInterval sets the interval between retries.
func (*HealthCheckStrategy) WithTestTimeout ¶
func (s *HealthCheckStrategy) WithTestTimeout(timeout time.Duration) *HealthCheckStrategy
WithTestTimeout sets timeout for running the test.
type HealthCheckTest ¶
type HealthCheckTest interface {
Test(ctx context.Context, target StrategyTarget) (success bool, err error)
}
HealthCheckTest tests for health check.
type HealthCheckTestFunc ¶
type HealthCheckTestFunc func(ctx context.Context, target StrategyTarget) (success bool, err error)
HealthCheckTestFunc is an inline test for health check.
func (HealthCheckTestFunc) Test ¶
func (f HealthCheckTestFunc) Test(ctx context.Context, target StrategyTarget) (success bool, err error)
Test checks if a container is healthy.
type SleepStrategy ¶
type SleepStrategy struct {
// contains filtered or unexported fields
}
SleepStrategy sleeps for an amount of time without checking anything.
func Sleep ¶
func Sleep(d time.Duration) *SleepStrategy
Sleep will sleep for an amount of time without checking anything.
func (*SleepStrategy) WaitUntilReady ¶
func (s *SleepStrategy) WaitUntilReady(ctx context.Context, _ wait.StrategyTarget) error
WaitUntilReady sleeps for an amount of time. It will return an error if context is canceled.
type Strategy ¶
Strategy is an alias of github.com/testcontainers/testcontainers-go/wait.Strategy to avoid extra import.
type StrategyTarget ¶
type StrategyTarget = wait.StrategyTarget
StrategyTarget is an alias of github.com/testcontainers/testcontainers-go/wait.StrategyTarget to avoid extra import.