Documentation
¶
Index ¶
- Variables
- type Check
- func Async(check Check, interval time.Duration) Check
- func AsyncWithContext(ctx context.Context, check Check, interval time.Duration) Check
- func CheckGRPC(grpcClient grpc_health_v1.HealthClient) Check
- func CheckRedis(client redis.Cmdable) Check
- func DNSResolveCheck(host string, timeout time.Duration) Check
- func DatabaseSelectCheck(client *sql.DB, timeout time.Duration) Check
- func GoroutineCountCheck(threshold int) Check
- func HTTPGetCheck(url string, timeout time.Duration) Check
- func TCPDialCheck(addr string, timeout time.Duration) Check
- func Timeout(check Check, timeout time.Duration) Check
- type TimeoutError
Constants ¶
This section is empty.
Variables ¶
var ErrNoData = errors.New("no data yet")
ErrNoData is returned if the first call of an Async() wrapped Check has not yet returned.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check func() error
Check is a health/readiness check.
func Async ¶
Async converts a Check into an asynchronous check that runs in a background goroutine at a fixed interval. The check is called at a fixed rate, not with a fixed delay between invocations. If your check takes longer than the interval to execute, the next execution will happen immediately.
Note: if you need to clean up the background goroutine, use AsyncWithContext().
func AsyncWithContext ¶
AsyncWithContext converts a Check into an asynchronous check that runs in a background goroutine at a fixed interval. The check is called at a fixed rate, not with a fixed delay between invocations. If your check takes longer than the interval to execute, the next execution will happen immediately.
Note: if you don't need to cancel execution (because this runs forever), use Async()
func CheckGRPC ¶
func CheckGRPC(grpcClient grpc_health_v1.HealthClient) Check
CheckRedis returns a Check function to check for readiness of given grpc service.
func CheckRedis ¶
CheckRedis returns a Check function that validates Redis connection.
func DNSResolveCheck ¶
DNSResolveCheck returns a Check that makes sure the provided host can resolve to at least one IP address within the specified timeout.
func DatabaseSelectCheck ¶
DatabaseSelectCheck returns a Check that validates connectivity to a database using `SELECT 1` query execution.
func GoroutineCountCheck ¶
GoroutineCountCheck returns a Check that fails if too many goroutines are running (which could indicate a resource leak).
func HTTPGetCheck ¶
HTTPGetCheck returns a Check that performs an HTTP GET request against the specified URL. The check fails if the response times out or returns a non-200 status code.
func TCPDialCheck ¶
TCPDialCheck returns a Check that checks TCP connectivity to the provided endpoint.
type TimeoutError ¶
TimeoutError is the error returned when a Timeout-wrapped Check takes too long
func (TimeoutError) Error ¶
func (e TimeoutError) Error() string
func (TimeoutError) Temporary ¶
func (e TimeoutError) Temporary() bool
Temporary returns whether this error is temporary (always true for timeoutError)
func (TimeoutError) Timeout ¶
func (e TimeoutError) Timeout() bool
Timeout returns whether this error is a timeout (always true for timeoutError)