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 path prefixes always allowed through (e.g., "/setup"). 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.