Documentation
¶
Overview ¶
Package processkit provides a standard-library process boundary for Modary applications: deterministic probes, pre-shutdown drain, active-request admission, and one shared HTTP server lifecycle. It contains no database, container-platform, or telemetry dependency.
Index ¶
- Constants
- func Serve(ctx context.Context, options ServerOptions) (resultErr error)
- type BuildInfo
- type Check
- type Manager
- func (manager *Manager) BeginDrain()
- func (manager *Manager) Drain(ctx context.Context) error
- func (manager *Manager) LivenessHandler() http.Handler
- func (manager *Manager) MarkReady() error
- func (manager *Manager) MarkStopped() error
- func (manager *Manager) Middleware(next http.Handler) (http.Handler, error)
- func (manager *Manager) Phase() Phase
- func (manager *Manager) ReadinessHandler() http.Handler
- type Options
- type Phase
- type ServerOptions
Constants ¶
const ( // DefaultCheckTimeout bounds one complete readiness evaluation. DefaultCheckTimeout = 2 * time.Second // MaximumChecks bounds the number of selected readiness dependencies. MaximumChecks = 32 )
const ( // DefaultReadHeaderTimeout bounds receipt of request headers. DefaultReadHeaderTimeout = 5 * time.Second // DefaultReadTimeout bounds receipt of the complete request. DefaultReadTimeout = 30 * time.Second // DefaultWriteTimeout bounds writing the complete response. DefaultWriteTimeout = 30 * time.Second // DefaultIdleTimeout bounds keep-alive connection idleness. DefaultIdleTimeout = 60 * time.Second // DefaultMaxHeaderBytes bounds request headers to one MiB. DefaultMaxHeaderBytes = 1 << 20 // MaximumHeaderBytes is the largest configurable request-header boundary. MaximumHeaderBytes = 16 << 20 )
const DefaultShutdownTimeout = 10 * time.Second
DefaultShutdownTimeout bounds server drain and application cleanup.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BuildInfo ¶
BuildInfo is immutable process identity injected by the consumer build. It deliberately excludes host, user, and other high-cardinality dimensions.
func NormalizeBuildInfo ¶
NormalizeBuildInfo validates bounded identity and supplies explicit local development defaults.
type Check ¶
Check is one bounded readiness dependency. Check functions must be safe for concurrent use and honor cancellation. Manager permits at most one in-flight invocation per check, preventing a noncooperative dependency from creating an unbounded goroutine count across repeated probes.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns process readiness and accepted HTTP work.
func (*Manager) BeginDrain ¶
func (manager *Manager) BeginDrain()
BeginDrain atomically disables readiness and new application admission. Repeated calls are safe.
func (*Manager) LivenessHandler ¶
LivenessHandler reports only local process state and never calls a remote dependency.
func (*Manager) MarkReady ¶
MarkReady enables traffic after application assembly and listener startup.
func (*Manager) MarkStopped ¶
MarkStopped records terminal local shutdown. It is valid only after drain.
func (*Manager) Middleware ¶
Middleware admits application requests only while ready. Exact probe paths remain reachable while draining so an orchestrator can observe the transition.
func (*Manager) ReadinessHandler ¶
ReadinessHandler runs bounded selected dependency checks only while the local lifecycle is ready.
type Phase ¶
type Phase string
Phase is the local admission lifecycle. Draining remains live but rejects new application work and reports unready.
const ( // PhaseStarting rejects traffic before assembly and listener startup finish. PhaseStarting Phase = "starting" // PhaseReady admits application traffic and enables dependency readiness. PhaseReady Phase = "ready" // PhaseDraining rejects new work while accepted work completes. PhaseDraining Phase = "draining" // PhaseStopped is the terminal process state after resources are released. PhaseStopped Phase = "stopped" )
type ServerOptions ¶
type ServerOptions struct {
Address string
Handler http.Handler
Manager *Manager
Logger *slog.Logger
Shutdown func(context.Context) error
ShutdownTimeout time.Duration
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int
Build BuildInfo
}
ServerOptions is the shared generated HTTP process contract.