observer

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package observer implements the observer polling loop and health check orchestration for monitoring Valkey cluster health.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHealthServer

func NewHealthServer(addr string, obs *Observer) *http.Server

NewHealthServer creates an HTTP server for observer health endpoints.

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the observer polling loop and health server. It blocks until the context is cancelled.

Types

type CheckResult

type CheckResult struct {
	Ready     bool            `json:"ready"`
	Checks    map[string]bool `json:"checks"`
	Message   string          `json:"message,omitempty"`
	LastCheck time.Time       `json:"lastCheck"`
}

CheckResult holds the outcome of a single check cycle.

type Config

type Config struct {
	Namespace         string
	ClusterName       string
	HealthAddr        string
	PollInterval      time.Duration
	ValkeyHeadlessSvc string
	Replicas          int
	Password          string

	// TLS settings.
	TLSEnabled bool
	TLSCACert  string
	TLSCert    string
	TLSKey     string

	// ValkeyMTLS controls whether the observer sends a client certificate to Valkey pods.
	// Default: true (mTLS enabled).
	ValkeyMTLS bool
	// SentinelMTLS controls whether the observer sends a client certificate to Sentinel pods.
	// Default: false (server-only TLS verification).
	SentinelMTLS bool

	// Sentinel settings.
	SentinelEnabled     bool
	SentinelAddrs       string
	SentinelAddrList    []string
	SentinelMonitor     string
	SentinelDisableAuth bool

	// Observer DB for health key.
	ObserverDB int
}

Config holds the observer configuration parsed from flags/env vars.

type Observer

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

Observer runs periodic health checks against a Valkey cluster.

func New

func New(cfg Config) (*Observer, error)

New creates a new Observer with the given configuration.

func (*Observer) GetResult

func (o *Observer) GetResult() CheckResult

GetResult returns the latest check result (thread-safe).

Jump to

Keyboard shortcuts

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