Documentation
¶
Overview ¶
Package configwait provides utilities for waiting on configuration availability during startup.
Index ¶
Constants ¶
const ( EnvMaxRetries = "CONFIG_WAIT_MAX_RETRIES" EnvRetryInterval = "CONFIG_WAIT_RETRY_INTERVAL" )
const ( DefaultMaxRetries = 30 DefaultRetryInterval = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
Config configures the wait behavior.
func NewConfigFromEnv ¶
func NewConfigFromEnv() Config
NewConfigFromEnv creates a Config from environment variables.
type ReadyGate ¶
type ReadyGate struct {
// contains filtered or unexported fields
}
ReadyGate gates HTTP requests until the service is ready.
func NewReadyGate ¶
NewReadyGate creates a ReadyGate wrapping the given handler.
The allowedPaths are always allowed through, even before the gate is ready. Each entry matches the path itself and anything beneath it on a path-segment boundary: "/setup" allows "/setup", "/setup/", and "/setup/disable", but not "/setupadmin". The entry "/" matches only the root path. Requests whose path is not canonical (dot segments, repeated slashes) never bypass the gate, so a path such as "/setup/../webhook" cannot reach a gated handler early.
The inner handler can be nil initially; call SetHandler() once ready.
func (*ReadyGate) ServeHTTP ¶
func (rg *ReadyGate) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*ReadyGate) SetHandler ¶
SetHandler sets the main handler to use once ready.
type ReloadFunc ¶
ReloadFunc is called when a reload is triggered.
type Reloader ¶
type Reloader struct {
// contains filtered or unexported fields
}
Reloader manages configuration reloading via SIGHUP or programmatic triggers.
func NewReloader ¶
func NewReloader(ctx context.Context, gate *ReadyGate, reloadFunc ReloadFunc) *Reloader
NewReloader creates a Reloader that calls reloadFunc when triggered.