Documentation
¶
Overview ¶
Package appsupervisor manages dev-server process lifecycle and readiness probing.
It exists to keep process control and health-check policy separate from higher-level watcher and hook orchestration code.
Index ¶
- Constants
- func DeriveReadinessWaitDelay(attemptIndex int, baseDelay time.Duration, maximumDelay time.Duration) time.Duration
- func ResolveAppReadyURL(appPort int, healthcheckEndpoint string) string
- func ResolveReadinessProbeURL(host string, port int, endpoint string) string
- func ShouldContinueReadinessWait(totalElapsed time.Duration, maximumTotal time.Duration) bool
- func ShouldIgnoreProcessTerminationError(processTerminationError error) bool
- func ShouldIgnoreProcessWaitError(processWaitError error) bool
- func WaitForAnyReady(urls []string, policy ReadinessWaitPolicy) bool
- func WaitForAnyReadyWithContext(readinessContext context.Context, urls []string, policy ReadinessWaitPolicy) bool
- type AppProcessManager
- type ReadinessWaitPolicy
Constants ¶
const ( // DefaultAppProcessGracefulStopTimeout is the default timeout for process stop. DefaultAppProcessGracefulStopTimeout = 6 * time.Second // LocalReadinessProbeHostIPv4 is the default host used for probe URL generation. LocalReadinessProbeHostIPv4 = "127.0.0.1" // LocalReadinessProbeHostLocalhost is alternate host used for probe fallback. LocalReadinessProbeHostLocalhost = "localhost" )
Variables ¶
This section is empty.
Functions ¶
func DeriveReadinessWaitDelay ¶
func DeriveReadinessWaitDelay( attemptIndex int, baseDelay time.Duration, maximumDelay time.Duration, ) time.Duration
DeriveReadinessWaitDelay computes delay using capped doubling backoff.
func ResolveAppReadyURL ¶
ResolveAppReadyURL resolves app healthcheck URL for given runtime port.
func ResolveReadinessProbeURL ¶
ResolveReadinessProbeURL builds a readiness URL from host/port/endpoint.
func ShouldContinueReadinessWait ¶
ShouldContinueReadinessWait reports whether elapsed time is still within budget.
func ShouldIgnoreProcessTerminationError ¶
ShouldIgnoreProcessTerminationError reports expected stop outcomes.
func ShouldIgnoreProcessWaitError ¶
ShouldIgnoreProcessWaitError reports expected wait outcomes from termination.
func WaitForAnyReady ¶
func WaitForAnyReady(urls []string, policy ReadinessWaitPolicy) bool
WaitForAnyReady polls URLs until one is healthy or timeout budget expires.
func WaitForAnyReadyWithContext ¶
func WaitForAnyReadyWithContext( readinessContext context.Context, urls []string, policy ReadinessWaitPolicy, ) bool
WaitForAnyReadyWithContext polls URLs until one is healthy, timeout budget expires, or context cancellation is observed.
Types ¶
type AppProcessManager ¶
type AppProcessManager struct {
GracefulStopTimeout time.Duration
// contains filtered or unexported fields
}
AppProcessManager owns lifecycle operations for the app runtime process.
func NewAppProcessManager ¶
func NewAppProcessManager() *AppProcessManager
NewAppProcessManager creates a new process manager.
func (*AppProcessManager) CurrentCommand ¶
func (processManager *AppProcessManager) CurrentCommand() *exec.Cmd
CurrentCommand returns the current tracked command pointer.
func (*AppProcessManager) StartApp ¶
func (processManager *AppProcessManager) StartApp( binaryPath string, ) (*exec.Cmd, error)
StartApp starts a new app process and records it as current command.
func (*AppProcessManager) StopApp ¶
func (processManager *AppProcessManager) StopApp(command *exec.Cmd) error
StopApp stops the provided command when it matches current running app.
func (*AppProcessManager) StopCurrentApp ¶
func (processManager *AppProcessManager) StopCurrentApp() error
StopCurrentApp stops the currently tracked app process.
type ReadinessWaitPolicy ¶
type ReadinessWaitPolicy struct {
HTTPClientTimeout time.Duration
InitialDelay time.Duration
MaximumDelay time.Duration
MaximumTotalWait time.Duration
TreatHTTPStatusCodeAsReady func(int) bool
}
ReadinessWaitPolicy defines polling behavior for readiness checks.
func DefaultReadinessWaitPolicy ¶
func DefaultReadinessWaitPolicy() ReadinessWaitPolicy
DefaultReadinessWaitPolicy returns robust defaults for local dev readiness polling.