Documentation
¶
Overview ¶
Package gsfiber is the Fiber v2 adapter for the gscore graceful-shutdown engine. See the sibling gsfiberv3 package for Fiber v3.
Index ¶
Constants ¶
const ( PhasePreStop = gscore.PhasePreStop PhaseDrain = gscore.PhaseDrain PhasePostDrain = gscore.PhasePostDrain PhaseDB = gscore.PhaseDB PhasePostDB = gscore.PhasePostDB )
Phase enum re-exports for ergonomic registration.
Variables ¶
This section is empty.
Functions ¶
func ListenAndTrigger ¶ added in v0.7.1
ListenAndTrigger starts the Fiber v2 app on addr in a goroutine. If app.Listen returns a non-nil error (e.g. port already in use), it calls mgr.Trigger() so the shutdown sequence starts instead of leaving the process hanging waiting for a signal that will never arrive.
Typical use at the end of main, after all routes are registered:
gsfiber.ListenAndTrigger(app, mgr, ":8080")
if err := mgr.ListenAndWait(); err != nil {
log.Fatal(err)
}
func LivenessHandler ¶ added in v0.7.1
LivenessHandler returns a Fiber v2 handler suitable for a Kubernetes liveness probe. It always returns 200 — if the process can respond to HTTP, it is alive. Keep this handler free of external dependencies (DB, cache, etc.) to avoid spurious pod restarts.
func ReadinessHandler ¶
ReadinessHandler returns a Fiber v2 handler suitable for a Kubernetes readiness probe. It returns 200 while the Manager is ready and 503 once shutdown has begun, so kube-proxy can remove the pod from service endpoints before in-flight requests are drained.
func RegisterApp ¶
RegisterApp adds a Fiber v2 app to be drained during the drain phase.
func StartupHandler ¶ added in v0.7.1
StartupHandler returns a Fiber v2 handler suitable for a Kubernetes startup probe. It returns 503 until MarkStarted is called on the Manager, and 200 afterwards. While the startup probe fails, Kubernetes suspends liveness and readiness probes, protecting pods with slow boot sequences (migrations, cache warm-up, etc.).