gslb

package module
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 48 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go lint Go tests Go coverage Lines of code Integration tests

release

CoreDNS-GSLB

What is CoreDNS-GSLB?

CoreDNS-GSLB is a plugin that provides Global Server Load Balancing functionality in CoreDNS. It intelligently routes your traffic to healthy backends based on geographic location, priority, or load balancing algorithms.

What it does:

  • Health monitoring of your backends with HTTP(S), TCP, ICMP, MySQL, gRPC, or custom Lua checks
  • Reusable healthcheck profiles: Define health check templates globally (in the Corefile) or per zone, and reference them by name in your backends
  • Geographic routing using MaxMind GeoIP databases or custom location mapping
  • Load balancing with failover, round-robin, random, weighted, IP-hash, GeoIP or GeoIP-affinity selection
  • Adaptive monitoring that reduces healthcheck frequency for idle records
  • Live configuration reload without restarting CoreDNS
  • Bulk backends management via API: Instantly enable or disable multiple backends by location or IP prefix
  • Supported record types: Serving dynamic responses for standard A, AAAA, CNAME, SRV, TXT, SVCB, and HTTPS queries based on backend status
  • CNAME Redirection for FQDN Backends: Support hostname/FQDN targets in backend pools, running healthchecks normally and automatically responding with CNAME records if selected
  • Wildcard record support: Support for standard DNS wildcard records (*.domain.tld)
  • Configurable failover policies: Choose how GSLB answers when all backends are unhealthy (fail-open, fail-closed with custom rcode, or fail-specific with fallback IPs)
  • Distributed HA Synchronization: Optional Redis-backed shared health checking with distributed locks (SETNX), offloaded probing support, and real-time Pub/Sub propagation to synchronize status across multiple CoreDNS instances.
  • No external database: Records are defined using a YAML file.
  • Dynamic backend discovery: Automatic backend pool construction via Consul, HTTP, or DNS (SVCB/HTTPS)

Unlike many existing solutions, this plugin is designed for non-Kubernetes infrastructures — including virtual machines, bare metal servers, and hybrid environments.

  • Non-Kubernetes focused: Designed for VMs, bare metal, and hybrid environments
  • Multiple health check types: From simple TCP to complex Lua scripting
  • Real client IP detection: EDNS Client Subnet support for accurate GeoIP routing
  • Resource efficient: Adaptive healthchecks reduce load on unused backends
  • Production ready: Prometheus metrics and comprehensive observability

🚀 Getting Started

To get up and running quickly using Docker Compose or to compile the plugin locally, check out the Getting Started Guide.

📚 Documentation

Topic Description
Getting Started Quickstart guide and Docker setup
Corefile Reference Complete Corefile parameter reference
Supported Records Supported record types (A, AAAA, SRV, SVCB/HTTPS, TXT, wildcards)
Selection & Failover Failover, round-robin, random, IP-hash, GeoIP, weighted, and failover policies
GeoIP Setup MaxMind databases and custom location mapping
Health Checks Active health checking (HTTP/S, TCP, ICMP, MySQL, gRPC, Lua) and profiles
Backend Discovery Static configs, defaults, tags, and dynamic discovery (Consul, HTTP, SVCB)
ECS Compliance EDNS Client Subnet compliance and caching scope
Architecture & Deployments Standalone and Cluster deployments, Anycast/BGP (RHI), and Consul integration
API Reference REST API endpoints and OpenAPI schema
CLI Guide Command-line client tool
Observability Prometheus metrics
Performance Benchmarks Resource usage and local benchmarking guides
Troubleshooting Troubleshooting and debugging
Developer Guide Development rules, docker environment, compilation, and testing

👥 Contributions

Contributions are welcome! Please read the Contributing Guide for local setup and testing instructions.

[!TIP] Check out these other open-source DNS utilities to enhance your DNS infrastructure monitoring and testing:

  • DNS-collector: A high-performance DNS traffic analyzer and collector. Grab your DNS logs, detect anomalies, and finally understand what's happening on your network in real-time.
  • DNS-tester: A comprehensive DNS testing and verification toolkit designed to validate DNS response behavior under various network conditions.

Documentation

Index

Constants

View Source
const ICMPType = "icmp"

Variables

View Source
var (
	GlobalHealthcheckProfiles map[string]*HealthCheck
	ProfilesMutex             sync.RWMutex
)

Global map for global healthcheck profiles loaded from Corefile

View Source
var Version = "dev"

Version of the GSLB plugin, set at build time

Functions

func IncBackendSelected added in v0.8.0

func IncBackendSelected(name, address string)

func IncConfigReloads added in v0.8.0

func IncConfigReloads(result string)

func IncHealthcheckFailures added in v0.8.0

func IncHealthcheckFailures(typ, address, reason string)

func IncHealthcheckTotal added in v0.3.0

func IncHealthcheckTotal(name, typ, address, result string)

func IncRecordResolutions added in v0.8.0

func IncRecordResolutions(name, result string)

func NewHTTPSTransport added in v0.19.0

func NewHTTPSTransport(cc *tls.Config) *http.Transport

func NewTLSClientConfig added in v0.19.0

func NewTLSClientConfig(certPath, keyPath, caPath string) (*tls.Config, error)

NewTLSConfig returns a TLS config that includes a certificate and key pair If caPath is empty, default root store will be used If certPath or keyPath are empty, client certificate will not be loaded

func ObserveHealthcheck added in v0.3.0

func ObserveHealthcheck(name, typeStr, address string, start time.Time, result bool)

func ObserveHealthcheckDuration added in v0.3.0

func ObserveHealthcheckDuration(typ, address string, duration float64)

func ObserveRecordResolutionDuration added in v0.8.0

func ObserveRecordResolutionDuration(name, result string, duration float64)

func RegisterMetrics added in v0.3.0

func RegisterMetrics()

func SetActiveBackends added in v0.8.0

func SetActiveBackends(name string, value float64)

func SetBackendHealthStatus added in v0.8.0

func SetBackendHealthStatus(name, address string, value float64)

func SetBackendHealthcheckStatus added in v0.8.0

func SetBackendHealthcheckStatus(name, address, typeStr string, value float64)

func SetBackendsTotal added in v0.8.0

func SetBackendsTotal(value float64)

func SetHealthchecksTotal added in v0.8.0

func SetHealthchecksTotal(value float64)

func SetRecordHealthStatus added in v0.8.0

func SetRecordHealthStatus(name string, value float64)

func SetRecordsTotal added in v0.8.0

func SetRecordsTotal(value float64)

func SetVersionInfo added in v0.8.0

func SetVersionInfo(version string)

func SetZonesTotal added in v0.10.0

func SetZonesTotal(value float64)

func WithClientInfo added in v0.3.0

func WithClientInfo(ctx context.Context, ip net.IP, prefix uint8) context.Context

Types

type Backend

type Backend struct {
	Fqdn            string               // Fully qualified domain name
	Description     string               // Description of the backend
	Address         string               // IP address or hostname
	Port            int                  // Port number of the backend
	Priority        int                  // Priority for load balancing
	Weight          int                  // Weight for weighted load balancing
	Enable          bool                 // Enable or disable the backend
	Tags            []string             // List of tags for filtering or grouping
	HealthChecks    []GenericHealthCheck `yaml:"healthchecks"` // Health check configurations
	Timeout         string               // Timeout for requests
	Alive           bool                 // Indicates if the backend is alive
	Continent       string               // Continent code for GeoIP (e.g. EU)
	Country         string               // Country code for GeoIP
	Subdivision     string               // Subdivision/state code for GeoIP (e.g. CA, NY)
	City            string               // City name for GeoIP
	ASN             string               // ASN for GeoIP
	Location        string               // location
	Longitude       float64              // Longitude for distance-based GeoIP routing
	Latitude        float64              // Latitude for distance-based GeoIP routing
	LongitudeRad    float64              // Precomputed longitude in radians for distance calculations
	LatitudeRad     float64              // Precomputed latitude in radians for distance calculations
	HasCoordinates  bool                 // Indicates whether both coordinates were explicitly configured
	LastHealthcheck time.Time            // Last time a healthcheck was launched
	AssumeHealthy   bool                 `yaml:"assume_healthy"` // Bypass healthchecks and assume UP
	Passive         bool                 `yaml:"passive"`        // Passive health checking, read from Redis only
	Rise            int                  `yaml:"rise" default:"2"`
	Fall            int                  `yaml:"fall" default:"3"`
	// contains filtered or unexported fields
}

Backend represents an individual backend with health check settings.

func (*Backend) ApplyHealthCheckResult added in v0.22.0

func (b *Backend) ApplyHealthCheckResult(alive bool)

func (*Backend) GetASN added in v0.9.0

func (b *Backend) GetASN() string

func (*Backend) GetAddress

func (b *Backend) GetAddress() string

func (*Backend) GetAssumeHealthy added in v0.21.0

func (b *Backend) GetAssumeHealthy() bool

func (*Backend) GetCity added in v0.9.0

func (b *Backend) GetCity() string

func (*Backend) GetContinent added in v0.18.0

func (b *Backend) GetContinent() string

func (*Backend) GetCountry added in v0.3.0

func (b *Backend) GetCountry() string

func (*Backend) GetDescription

func (b *Backend) GetDescription() string

func (*Backend) GetFall added in v0.21.0

func (b *Backend) GetFall() int

func (*Backend) GetFqdn

func (b *Backend) GetFqdn() string

func (*Backend) GetHealthChecks

func (b *Backend) GetHealthChecks() []GenericHealthCheck

func (*Backend) GetLastHealthcheck added in v0.22.0

func (b *Backend) GetLastHealthcheck() time.Time

func (*Backend) GetLatitude added in v0.18.0

func (b *Backend) GetLatitude() float64

func (*Backend) GetLatitudeRad added in v0.18.0

func (b *Backend) GetLatitudeRad() float64

func (*Backend) GetLocation added in v0.3.0

func (b *Backend) GetLocation() string

func (*Backend) GetLongitude added in v0.18.0

func (b *Backend) GetLongitude() float64

func (*Backend) GetLongitudeRad added in v0.18.0

func (b *Backend) GetLongitudeRad() float64

func (*Backend) GetPort added in v0.21.0

func (b *Backend) GetPort() int

func (*Backend) GetPriority

func (b *Backend) GetPriority() int

func (*Backend) GetRise added in v0.21.0

func (b *Backend) GetRise() int

func (*Backend) GetSubdivision added in v0.18.0

func (b *Backend) GetSubdivision() string

func (*Backend) GetTags added in v0.12.0

func (b *Backend) GetTags() []string

func (*Backend) GetTimeout

func (b *Backend) GetTimeout() string

func (*Backend) GetWeight added in v0.12.0

func (b *Backend) GetWeight() int

func (*Backend) HasGeoCoordinates added in v0.18.0

func (b *Backend) HasGeoCoordinates() bool

func (*Backend) IsAlive added in v0.22.0

func (b *Backend) IsAlive() bool

func (*Backend) IsEnabled

func (b *Backend) IsEnabled() bool

func (*Backend) IsHealthy

func (b *Backend) IsHealthy() bool

func (*Backend) IsPassive added in v0.22.0

func (b *Backend) IsPassive() bool

func (*Backend) Lock

func (b *Backend) Lock()

func (*Backend) SetAlive added in v0.22.0

func (b *Backend) SetAlive(alive bool)

func (*Backend) SetFqdn

func (b *Backend) SetFqdn(fqdn string)

func (*Backend) SetLastHealthcheck added in v0.22.0

func (b *Backend) SetLastHealthcheck(t time.Time)

func (*Backend) Unlock

func (b *Backend) Unlock()

func (*Backend) UnmarshalYAML

func (b *Backend) UnmarshalYAML(unmarshal func(interface{}) error) error

type BackendInterface

type BackendInterface interface {
	GetFqdn() string
	SetFqdn(fqdn string)
	GetDescription() string
	GetAddress() string
	GetPort() int
	GetPriority() int
	GetWeight() int
	IsEnabled() bool
	GetAssumeHealthy() bool
	IsPassive() bool
	GetRise() int
	GetFall() int
	GetTags() []string
	GetHealthChecks() []GenericHealthCheck
	GetTimeout() string
	GetContinent() string
	GetCountry() string
	GetSubdivision() string
	GetCity() string
	GetASN() string
	GetLocation() string
	GetLongitude() float64
	GetLatitude() float64
	GetLongitudeRad() float64
	GetLatitudeRad() float64
	HasGeoCoordinates() bool
	IsHealthy() bool
	IsAlive() bool
	SetAlive(alive bool)
	GetLastHealthcheck() time.Time
	SetLastHealthcheck(t time.Time)

	ApplyHealthCheckResult(alive bool)

	Lock()
	Unlock()
	// contains filtered or unexported methods
}

type BackendState added in v0.22.0

type BackendState struct {
	Status         string    `json:"status"` // "healthy" or "unhealthy"
	LastCheck      time.Time `json:"last_check"`
	LastResolution time.Time `json:"last_resolution"`
}

type ClientInfo added in v0.3.0

type ClientInfo struct {
	IP        net.IP
	PrefixLen uint8
}

func GetClientInfo added in v0.3.0

func GetClientInfo(ctx context.Context) *ClientInfo

type CustomSubnet added in v0.21.0

type CustomSubnet struct {
	Subnet   string
	IPNet    *net.IPNet
	Location string
}

type DiscoveredEndpoint added in v0.21.0

type DiscoveredEndpoint struct {
	Address string
	Port    int
}

type DiscoveryConfig added in v0.21.0

type DiscoveryConfig struct {
	Type     string `yaml:"type"`
	Endpoint string `yaml:"endpoint"`
	Service  string `yaml:"service"`
	Interval string `yaml:"interval"`
	Tag      string `yaml:"tag"`
}

func (*DiscoveryConfig) FetchEndpoints added in v0.21.0

func (d *DiscoveryConfig) FetchEndpoints() ([]DiscoveredEndpoint, error)

type FallbackPolicy added in v0.22.0

type FallbackPolicy struct {
	Mode          string   `yaml:"mode"`
	FallbackIPs   []string `yaml:"fallback_ips"`
	FallbackCNAME string   `yaml:"fallback_cname"`
	Rcode         string   `yaml:"rcode"`
}

FallbackPolicy represents the behavior of the record when all backends are unhealthy/disabled.

type GRPCHealthCheck added in v0.3.0

type GRPCHealthCheck struct {
	Host          string        `yaml:"host"`
	Port          int           `yaml:"port"`
	Service       string        `yaml:"service"`
	Timeout       time.Duration `yaml:"timeout"`
	EnableTLS     bool          `yaml:"enable_tls"`
	Cert          string        `yaml:"cert_path"`
	Key           string        `yaml:"key_path"`
	CA            string        `yaml:"ca_path"`
	SkipTLSVerify bool          `yaml:"skip_tls_verify"`
}

func (*GRPCHealthCheck) Check added in v0.3.0

func (h *GRPCHealthCheck) Check() error

func (*GRPCHealthCheck) Equals added in v0.3.0

func (h *GRPCHealthCheck) Equals(other GenericHealthCheck) bool

func (*GRPCHealthCheck) GetType added in v0.3.0

func (h *GRPCHealthCheck) GetType() string

func (*GRPCHealthCheck) PerformCheck added in v0.3.0

func (h *GRPCHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

func (*GRPCHealthCheck) SetDefault added in v0.3.0

func (h *GRPCHealthCheck) SetDefault()

type GSLB

type GSLB struct {
	Next                plugin.Handler
	Zones               map[string]string             // List of authoritative domains
	Records             map[string]map[string]*Record // zone -> fqdn -> record
	HealthcheckProfiles map[string]*HealthCheck       `yaml:"healthcheck_profiles"`

	Zone                      string   // Zone attendue pour la vérification des records
	LastResolution            sync.Map // key: domain (string), value: time.Time
	RoundRobinIndex           sync.Map
	MaxStaggerStart           string
	BatchSizeStart            int
	ResolutionIdleTimeout     string
	ResolutionIdleMultiplier  int // Multiplier for slow healthcheck interval
	HealthcheckIdleMultiplier int // Multiplier for slow healthcheck interval
	Mutex                     sync.RWMutex
	LocationMapMutex          sync.Mutex
	UseEDNSCSubnet            bool
	LocationMap               map[string]string
	LocationMapIPNet          []CustomSubnet
	GeoIPCountryDB            *geoip2.Reader // Loaded MaxMind DB (country)
	GeoIPCityDB               *geoip2.Reader // Loaded MaxMind DB (city)
	GeoIPASNDB                *geoip2.Reader // Loaded MaxMind DB (ASN)
	APIEnable                 bool           // Enable/disable API HTTP server
	APICertPath               string         // TLS certificate path for API
	APIKeyPath                string         // TLS key path for API
	APIListenAddr             string         // API listen address (default 0.0.0.0)
	APIListenPort             string         // API listen port (default 8080)
	APIBasicUser              string         // HTTP Basic Auth username (optional)
	APIBasicPass              string         // HTTP Basic Auth password (optional)
	// DisableTXT disables TXT record resolution if set to true
	DisableTXT bool

	RedisEnable    bool
	RedisAddr      string
	RedisPassword  string
	RedisDB        int
	RedisKeyPrefix string
	RedisSyncMode  string

	StatePersistEnable   bool
	StatePersistPath     string
	StatePersistInterval string
	StateMaxAge          string
	// contains filtered or unexported fields
}

func (*GSLB) AcquireRedisLock added in v0.22.0

func (g *GSLB) AcquireRedisLock(ctx context.Context, zone, fqdn, address string, ttl time.Duration) (bool, error)

AcquireRedisLock attempts to acquire a lock for performing a health check.

func (*GSLB) ConnectRedis added in v0.22.0

func (g *GSLB) ConnectRedis() error

ConnectRedis initializes the Redis client and starts the Pub/Sub subscriber.

func (*GSLB) GetHealthcheckIdleMultiplier added in v0.23.0

func (g *GSLB) GetHealthcheckIdleMultiplier() int

func (*GSLB) GetMaxStaggerStart

func (g *GSLB) GetMaxStaggerStart() time.Duration

func (*GSLB) GetRedisHealth added in v0.22.0

func (g *GSLB) GetRedisHealth(ctx context.Context, zone, fqdn, address string) (bool, error)

GetRedisHealth fetches the current health check result from Redis.

func (*GSLB) GetResolutionIdleTimeout

func (g *GSLB) GetResolutionIdleTimeout() time.Duration

func (*GSLB) LoadState added in v0.22.0

func (g *GSLB) LoadState() error

LoadState reads the persisted state from disk and applies it.

func (*GSLB) Name

func (g *GSLB) Name() string

func (*GSLB) RegisterAPIHandlers added in v0.9.0

func (g *GSLB) RegisterAPIHandlers(mux *http.ServeMux)

RegisterAPIHandlers registers all API endpoints to the provided mux.

func (*GSLB) SaveState added in v0.22.0

func (g *GSLB) SaveState() error

SaveState serializes the current health check state and last resolution times to disk.

func (*GSLB) ServeAPI added in v0.9.0

func (g *GSLB) ServeAPI()

func (*GSLB) ServeDNS

func (g *GSLB) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

func (*GSLB) SetRedisHealth added in v0.22.0

func (g *GSLB) SetRedisHealth(ctx context.Context, zone, fqdn, address string, alive bool, ttl time.Duration) error

SetRedisHealth stores the health check result in Redis and publishes it.

func (*GSLB) StartStatePersistLoop added in v0.22.0

func (g *GSLB) StartStatePersistLoop(ctx context.Context)

StartStatePersistLoop starts the periodic state saving background loop.

func (*GSLB) UnmarshalYAML added in v0.9.0

func (g *GSLB) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements custom YAML unmarshaling to handle healthcheck_profiles

type GenericHealthCheck

type GenericHealthCheck interface {
	// PerformCheck executes the health check for a backend.
	PerformCheck(backend *Backend, fdqn string, maxRetries int) bool

	// GetType returns the type of the health check (e.g., "http/80").
	GetType() string

	// Equals compares the current health check with another instance for equality.
	Equals(other GenericHealthCheck) bool
}

GenericHealthCheck defines a common interface for health checks

type HTTPHealthCheck

type HTTPHealthCheck struct {
	Port          int               `yaml:"port" default:"443"`
	EnableTLS     bool              `yaml:"enable_tls" default:"true"`
	Cert          string            `yaml:"cert_path" default:""`
	Key           string            `yaml:"key_path" default:""`
	CA            string            `yaml:"ca_path" default:""`
	URI           string            `yaml:"uri" default:"/"`
	Method        string            `yaml:"method" default:"GET"`
	Host          string            `yaml:"host" default:"localhost"`
	Headers       map[string]string `yaml:"headers"`
	Timeout       string            `yaml:"timeout" default:"5s"`
	ExpectedCode  int               `yaml:"expected_code" default:"200"`
	ExpectedBody  string            `yaml:"expected_body" default:""`
	SkipTLSVerify bool              `yaml:"skip_tls_verify" default:"false"`
}

HTTPHealthCheck represents HTTP-specific health check settings.

func (*HTTPHealthCheck) Equals

func (h *HTTPHealthCheck) Equals(other GenericHealthCheck) bool

Equals compares two HTTPHealthCheck objects for equality.

func (*HTTPHealthCheck) GetType

func (h *HTTPHealthCheck) GetType() string

func (*HTTPHealthCheck) PerformCheck

func (h *HTTPHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

PerformCheck implements the HealthCheck interface for HTTP health checks

func (*HTTPHealthCheck) SetDefault

func (h *HTTPHealthCheck) SetDefault()

type HealthCheck

type HealthCheck struct {
	Type   string                 `yaml:"type"`
	Params map[string]interface{} `yaml:"params"`
	Rise   int                    `yaml:"rise"`
	Fall   int                    `yaml:"fall"`
}

func ResolveHealthcheckProfile added in v0.9.0

func ResolveHealthcheckProfile(profileName string, localProfiles map[string]*HealthCheck) (*HealthCheck, error)

ResolveProfile resolves a healthcheck profile to a concrete HealthCheck

func (*HealthCheck) ToSpecificHealthCheck

func (hc *HealthCheck) ToSpecificHealthCheck() (GenericHealthCheck, error)

type ICMPHealthCheck

type ICMPHealthCheck struct {
	Count   int    `yaml:"count" default:"3"`    // Number of ICMP packets to send
	Timeout string `yaml:"timeout" default:"5s"` // Maximum duration for pings
}

ICMPHealthCheck represents the configuration for an ICMP health check.

func (*ICMPHealthCheck) Equals

func (h *ICMPHealthCheck) Equals(other GenericHealthCheck) bool

Equals compares two ICMPHealthCheck objects for equality.

func (*ICMPHealthCheck) GetType

func (h *ICMPHealthCheck) GetType() string

GetType returns the type of the health check as a string.

func (*ICMPHealthCheck) PerformCheck

func (h *ICMPHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

PerformCheck executes the ICMP health check for a backend.

func (*ICMPHealthCheck) SetDefault

func (h *ICMPHealthCheck) SetDefault()

SetDefault applies default values to ICMPHealthCheck fields.

type LuaHealthCheck added in v0.8.0

type LuaHealthCheck struct {
	Script  string                                  `yaml:"script"`
	Timeout time.Duration                           `yaml:"timeout"`
	Proto   atomic.Pointer[gopherlua.FunctionProto] `yaml:"-"`
}

func (*LuaHealthCheck) Equals added in v0.8.0

func (l *LuaHealthCheck) Equals(other GenericHealthCheck) bool

func (*LuaHealthCheck) GetType added in v0.8.0

func (l *LuaHealthCheck) GetType() string

func (*LuaHealthCheck) PerformCheck added in v0.8.0

func (l *LuaHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

func (*LuaHealthCheck) SetDefault added in v0.8.0

func (l *LuaHealthCheck) SetDefault()

type MockHealthCheck

type MockHealthCheck struct{}

Mock a health check that always returns true (successful) For testing purpose

func (*MockHealthCheck) Equals

func (hc *MockHealthCheck) Equals(other GenericHealthCheck) bool

func (*MockHealthCheck) GetType

func (hc *MockHealthCheck) GetType() string

func (*MockHealthCheck) PerformCheck

func (hc *MockHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

type MySQLHealthCheck added in v0.3.0

type MySQLHealthCheck struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port" default:"3306"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
	Timeout  string `yaml:"timeout" default:"3s"`
	Query    string `yaml:"query" default:"SELECT 1"`
}

MySQLHealthCheck represents MySQL-specific health check settings.

func (*MySQLHealthCheck) Equals added in v0.3.0

func (h *MySQLHealthCheck) Equals(other GenericHealthCheck) bool

func (*MySQLHealthCheck) GetType added in v0.3.0

func (h *MySQLHealthCheck) GetType() string

func (*MySQLHealthCheck) PerformCheck added in v0.3.0

func (h *MySQLHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

func (*MySQLHealthCheck) SetDefault added in v0.3.0

func (h *MySQLHealthCheck) SetDefault()

type Pinger

type Pinger interface {
	Run() error
	Statistics() *probing.Statistics
	SetPrivileged(privileged bool)
}

type RealPinger

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

func (*RealPinger) Run

func (r *RealPinger) Run() error

func (*RealPinger) SetPrivileged

func (r *RealPinger) SetPrivileged(privileged bool)

func (*RealPinger) Statistics

func (r *RealPinger) Statistics() *probing.Statistics

type Record

type Record struct {
	Fqdn           string
	Zone           string
	Mode           string
	Backends       []BackendInterface
	Owner          string
	Description    string
	RecordTTL      int
	ScrapeInterval string
	ScrapeRetries  int
	ScrapeTimeout  string
	FallbackPolicy FallbackPolicy
	Discovery      *DiscoveryConfig
	ALPN           []string
	// contains filtered or unexported fields
}

Record represents a GSLB record in the YAML config.

func (*Record) GetScrapeInterval

func (r *Record) GetScrapeInterval() time.Duration

GetScrapeInterval returns the health check interval for HTTPHealthCheck

func (*Record) GetScrapeTimeout

func (r *Record) GetScrapeTimeout() time.Duration

GetScrapeTimeout returns the health check timeout for HTTPHealthCheck

func (*Record) UnmarshalYAML

func (r *Record) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*Record) UpdateRecord added in v0.8.0

func (r *Record) UpdateRecord()

type RedisHealthUpdate added in v0.22.0

type RedisHealthUpdate struct {
	Zone    string `json:"zone"`
	Fqdn    string `json:"fqdn"`
	Address string `json:"address"`
	Alive   bool   `json:"alive"`
}

type TCPHealthCheck

type TCPHealthCheck struct {
	Port    int    `yaml:"port" default:"80"`    // TCP port to connect to
	Timeout string `yaml:"timeout" default:"5s"` // Timeout for the TCP connection
}

TCPHealthCheck represents TCP-specific health check settings.

func (*TCPHealthCheck) Equals

func (h *TCPHealthCheck) Equals(other GenericHealthCheck) bool

Equals compares two TCPHealthCheck objects for equality.

func (*TCPHealthCheck) GetType

func (h *TCPHealthCheck) GetType() string

GetType returns the type of the health check as a string.

func (*TCPHealthCheck) PerformCheck

func (h *TCPHealthCheck) PerformCheck(backend *Backend, fqdn string, maxRetries int) bool

PerformCheck implements the health check logic for TCP connections.

func (*TCPHealthCheck) SetDefault

func (h *TCPHealthCheck) SetDefault()

SetDefault applies default values to TCPHealthCheck fields.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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