lifecycle

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package lifecycle provides application lifecycle management including graceful shutdown and runtime reloading via SIGHUP signal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(
	createApp func() (Application, error),
	log *slog.Logger,
) error

Run runs an application with SIGTERM/SIGINT handling only (no SIGHUP reload). Used by shunt in KV mode where rule changes are picked up live via KV Watch.

Types

type Application

type Application interface {
	// Run starts the application and blocks until the context is cancelled.
	// It should handle all application logic including starting servers,
	// processing messages, and monitoring for shutdown signals.
	//
	// Returns an error if the application encounters a fatal error during
	// operation. Normal shutdown should return nil.
	Run(ctx context.Context) error

	// Close gracefully shuts down the application, releasing all resources.
	// This includes:
	// - Draining in-flight messages
	// - Closing NATS connections
	// - Shutting down HTTP servers
	// - Stopping background goroutines
	// - Syncing logs and metrics
	//
	// Close should be idempotent and safe to call multiple times.
	Close() error
}

Application represents a runnable application that supports graceful shutdown and runtime reloading. Both shunt and http-gateway implement this interface.

Jump to

Keyboard shortcuts

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