wait

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Overview

Package wait provides strategies for checking if a container is ready.

Index

Constants

View Source
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

type Strategy = wait.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL