checks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package checks provides built-in health checkers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheChecker

type CacheChecker struct {
	// contains filtered or unexported fields
}

CacheChecker checks cache (Redis) connectivity.

func NewCacheChecker

func NewCacheChecker(cache Pinger, opts ...CacheOption) *CacheChecker

NewCacheChecker creates a new cache health checker.

func (*CacheChecker) Check

Check performs the cache health check.

func (*CacheChecker) Name

func (c *CacheChecker) Name() string

Name returns the name of this health check.

func (*CacheChecker) Severity

func (c *CacheChecker) Severity() health.Severity

Severity returns the severity level of this check.

type CacheOption

type CacheOption func(*CacheChecker)

CacheOption is a functional option for CacheChecker.

func WithCacheSeverity

func WithCacheSeverity(s health.Severity) CacheOption

WithCacheSeverity sets the severity level.

func WithCacheTimeout

func WithCacheTimeout(d time.Duration) CacheOption

WithCacheTimeout sets the ping timeout.

type CustomChecker

type CustomChecker struct {
	// contains filtered or unexported fields
}

CustomChecker allows defining custom health checks with a function.

func NewCustomChecker

func NewCustomChecker(name string, checkFn func(ctx context.Context) health.CheckResult, opts ...CustomOption) *CustomChecker

NewCustomChecker creates a new custom health checker.

func (*CustomChecker) Check

Check performs the custom health check.

func (*CustomChecker) Name

func (c *CustomChecker) Name() string

Name returns the name of this health check.

func (*CustomChecker) Severity

func (c *CustomChecker) Severity() health.Severity

Severity returns the severity level of this check.

type CustomOption

type CustomOption func(*CustomChecker)

CustomOption is a functional option for CustomChecker.

func WithCustomSeverity

func WithCustomSeverity(s health.Severity) CustomOption

WithCustomSeverity sets the severity level.

type DatabaseChecker

type DatabaseChecker struct {
	// contains filtered or unexported fields
}

DatabaseChecker checks database connectivity.

func NewDatabaseChecker

func NewDatabaseChecker(db *sql.DB, opts ...DatabaseOption) *DatabaseChecker

NewDatabaseChecker creates a new database health checker.

func (*DatabaseChecker) Check

Check performs the database health check.

func (*DatabaseChecker) Name

func (c *DatabaseChecker) Name() string

Name returns the name of this health check.

func (*DatabaseChecker) Severity

func (c *DatabaseChecker) Severity() health.Severity

Severity returns the severity level of this check.

type DatabaseOption

type DatabaseOption func(*DatabaseChecker)

DatabaseOption is a functional option for DatabaseChecker.

func WithDatabaseSeverity

func WithDatabaseSeverity(s health.Severity) DatabaseOption

WithDatabaseSeverity sets the severity level.

func WithDatabaseTimeout

func WithDatabaseTimeout(d time.Duration) DatabaseOption

WithDatabaseTimeout sets the ping timeout.

type DiskChecker

type DiskChecker struct {
	// contains filtered or unexported fields
}

DiskChecker checks disk space availability.

func NewDiskChecker

func NewDiskChecker(path string, opts ...DiskOption) *DiskChecker

NewDiskChecker creates a new disk space health checker.

func (*DiskChecker) Check

Check performs the disk space health check.

func (*DiskChecker) Name

func (c *DiskChecker) Name() string

Name returns the name of this health check.

func (*DiskChecker) Severity

func (c *DiskChecker) Severity() health.Severity

Severity returns the severity level of this check.

type DiskOption

type DiskOption func(*DiskChecker)

DiskOption is a functional option for DiskChecker.

func WithDiskSeverity

func WithDiskSeverity(s health.Severity) DiskOption

WithDiskSeverity sets the severity level.

func WithDiskThreshold

func WithDiskThreshold(t float64) DiskOption

WithDiskThreshold sets the free space threshold percentage. If free space falls below this threshold, status will be degraded.

type MemoryChecker

type MemoryChecker struct {
	// contains filtered or unexported fields
}

MemoryChecker checks memory usage.

func NewMemoryChecker

func NewMemoryChecker(opts ...MemoryOption) *MemoryChecker

NewMemoryChecker creates a new memory health checker.

func (*MemoryChecker) Check

Check performs the memory health check.

func (*MemoryChecker) Name

func (c *MemoryChecker) Name() string

Name returns the name of this health check.

func (*MemoryChecker) Severity

func (c *MemoryChecker) Severity() health.Severity

Severity returns the severity level of this check.

type MemoryOption

type MemoryOption func(*MemoryChecker)

MemoryOption is a functional option for MemoryChecker.

func WithMemorySeverity

func WithMemorySeverity(s health.Severity) MemoryOption

WithMemorySeverity sets the severity level.

func WithMemoryThreshold

func WithMemoryThreshold(t float64) MemoryOption

WithMemoryThreshold sets the threshold percentage.

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger is an interface for services that can be pinged.

Jump to

Keyboard shortcuts

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