check

package
v0.0.0-...-aca2af5 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check interface {
	// Check performs the health check and returns an error if unhealthy
	Check(ctx context.Context) error
}

Check is the interface that all health checks must implement.

func All

func All(checks ...Check) Check

All creates a health check that requires all checks to pass.

func Any

func Any(checks ...Check) Check

Any creates a health check that requires at least one check to pass.

func WithRetries

func WithRetries(check Check, attempts int, delay time.Duration) Check

WithRetries wraps a Check with retry logic.

func WithThreshold

func WithThreshold(threshold int, checks ...Check) Check

WithThreshold creates a health check that requires a minimum number of checks to pass.

func WithTimeout

func WithTimeout(check Check, timeout time.Duration) Check

WithTimeout wraps a Check with a timeout.

type CheckFunc

type CheckFunc func(ctx context.Context) error

CheckFunc is a function type that implements the Check interface.

func (CheckFunc) Check

func (f CheckFunc) Check(ctx context.Context) error

Check implements the Check interface for CheckFunc.

type Config

type Config struct {
	Timeout    time.Duration
	Retries    int
	RetryDelay time.Duration
}

Config holds common configuration for health checks.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

func (Config) WithRetries

func (c Config) WithRetries(retries int) Config

WithRetries sets the number of retries for the health check.

func (Config) WithRetryDelay

func (c Config) WithRetryDelay(delay time.Duration) Config

WithRetryDelay sets the delay between retries.

func (Config) WithTimeout

func (c Config) WithTimeout(timeout time.Duration) Config

WithTimeout sets the timeout for the health check.

Directories

Path Synopsis
database
network
dns
tcp
udp
queue

Jump to

Keyboard shortcuts

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