gsfiber

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
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

func ListenAndTrigger(app *fiber.App, m *Manager, addr string)

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

func LivenessHandler() fiber.Handler

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

func ReadinessHandler(m *Manager) fiber.Handler

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

func RegisterApp(m *Manager, app *fiber.App)

RegisterApp adds a Fiber v2 app to be drained during the drain phase.

func StartupHandler added in v0.7.1

func StartupHandler(m *Manager) fiber.Handler

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.).

Types

type Config

type Config = gscore.Config

Config re-exports the core Config.

type Hook

type Hook = gscore.Hook

Hook re-exports the core Hook.

type Manager

type Manager = gscore.Manager

Manager re-exports the core Manager so callers do not need a second import for the common case.

func New

func New(cfg Config) *Manager

New constructs a Manager with the given Config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL