{"modulePath":"github.com/cruxstack/github-app-setup-go","version":"v0.8.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package configwait\n\nPackage configwait provides utilities for waiting on configuration availability during startup.\n\n## Constants\n\n```go\nconst (\n\tEnvMaxRetries    = \"CONFIG_WAIT_MAX_RETRIES\"\n\tEnvRetryInterval = \"CONFIG_WAIT_RETRY_INTERVAL\"\n)\n```\n\n```go\nconst (\n\tDefaultMaxRetries    = 30\n\tDefaultRetryInterval = 2 * time.Second\n)\n```\n\n## Functions\n\n```go\nfunc Wait(ctx context.Context, cfg Config, load LoadFunc) error\n```\nWait blocks until load succeeds or max retries is reached. Load is always attempted at least once, even if MaxRetries is zero or negative.\n\n## Types\n\n```go\ntype Config struct {\n\tMaxRetries    int\n\tRetryInterval time.Duration\n}\n```\nConfig configures the wait behavior.\n\n```go\nfunc NewConfigFromEnv() Config\n```\nNewConfigFromEnv creates a Config from environment variables.\n\n```go\ntype LoadFunc func(ctx context.Context) error\n```\nLoadFunc attempts to load configuration; returns nil on success.\n\n```go\ntype ReadyGate struct {\n\t// contains filtered or unexported fields\n}\n```\nReadyGate gates HTTP requests until the service is ready.\n\n```go\nfunc NewReadyGate(inner http.Handler, allowedPaths []string) *ReadyGate\n```\nNewReadyGate creates a ReadyGate wrapping the given handler.\n\nThe 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.\n\nThe inner handler can be nil initially; call SetHandler() once ready.\n\n```go\nfunc (rg *ReadyGate) IsReady() bool\n```\nIsReady returns true if the service is ready.\n\n```go\nfunc (rg *ReadyGate) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP implements http.Handler.\n\n```go\nfunc (rg *ReadyGate) SetHandler(h http.Handler)\n```\nSetHandler sets the main handler to use once ready.\n\n```go\nfunc (rg *ReadyGate) SetReady()\n```\nSetReady marks the service as ready to handle all requests.\n\n```go\ntype ReloadFunc func(ctx context.Context) error\n```\nReloadFunc is called when a reload is triggered.\n\n```go\ntype Reloader struct {\n\t// contains filtered or unexported fields\n}\n```\nReloader manages configuration reloading via SIGHUP or programmatic triggers.\n\n```go\nfunc NewReloader(ctx context.Context, gate *ReadyGate, reloadFunc ReloadFunc) *Reloader\n```\nNewReloader creates a Reloader that calls reloadFunc when triggered.\n\n```go\nfunc (r *Reloader) Start() \u003c-chan struct{}\n```\nStart begins listening for SIGHUP signals and programmatic triggers. Returns a channel that closes when the reloader stops.\n\n```go\nfunc (r *Reloader) Trigger()\n```\nTrigger requests a configuration reload. Safe to call from any goroutine.\n\n","path":"github.com/cruxstack/github-app-setup-go/configwait","name":"configwait","synopsis":"Package configwait provides utilities for waiting on configuration availability during startup.","isRedistributable":true}
