Documentation
¶
Overview ¶
Package server orchestrates the load balancer, discovery, and health subsystems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAPIPort ¶ added in v0.2.0
ExtractAPIPort returns the port from the first endpoint, or "6443" as default.
Types ¶
type Option ¶ added in v0.2.0
type Option func(*Server)
Option configures a Server.
func WithDiscoveryProviders ¶ added in v0.3.0
func WithDiscoveryProviders(providers ...discovery.EndpointProvider) Option
WithDiscoveryProviders overrides the discovery providers used by the server. Intended for testing the discovery pipeline exit path. Panics if no providers are given.
func WithHealthServer ¶ added in v0.3.0
func WithHealthServer(hs healthServer) Option
WithHealthServer injects a custom health server implementation (for testing).
func WithKubeClient ¶ added in v0.2.0
func WithKubeClient(client kubernetes.Interface) Option
WithKubeClient injects a pre-built Kubernetes client for endpoint discovery.
func WithLivenessConfig ¶ added in v0.3.0
WithLivenessConfig overrides the heartbeat interval and liveness threshold from Config.LivenessInterval and Config.LivenessThreshold. Intended for testing with sub-second intervals that would be rejected by config validation. Both values must be positive, and threshold must be greater than interval. Panics on invalid values.
func WithLivenessProbe ¶ added in v0.3.0
func WithLivenessProbe(probe func()) Option
WithLivenessProbe overrides the function the heartbeat goroutine uses to probe system health. The default probes the load balancer. Intended for testing deadlock detection with a blocking probe. Panics if probe is nil.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server ties together the load balancer, endpoint discovery, and health checking.
func New ¶
New creates a Server from the given config. Config is expected to be pre-validated by the caller; ApplyDefaults and Validate are retained as defense-in-depth for direct callers and tests.
func (*Server) Alive ¶ added in v0.3.0
Alive reports whether the server's Run loop is active and responsive. Returns false when:
- Run has not been called yet (lastHeartbeat == 0)
- Run has returned (lastHeartbeat reset to 0)
- The heartbeat probe has not responded within the liveness threshold (indicating a deadlocked load balancer goroutine)
- The discovery pipeline has exited unexpectedly