lifecycle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package lifecycle provides graceful shutdown coordination for GRIP components.

It exposes the Shutdown coordinator which supports:

  • Idempotent shutdown initiation
  • LIFO hook execution (last registered, first executed)
  • Shutdown reason tracking
  • Context-based cancellation propagation

Usage

sd := lifecycle.NewShutdown()
sd.Register(func() { server.GracefulStop() })
sd.Register(func() { db.Close() })

// Later, during shutdown:
sd.Shutdown("SIGTERM received")
// Hooks execute in reverse order: db.Close() then server.GracefulStop()

The Shutdown coordinator is thread-safe and can be shared across multiple GRIP pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shutdown

type Shutdown = lifecycle.Shutdown

Shutdown coordinates graceful shutdown of GRIP components.

It implements core.ShutdownCoordinator and provides:

  • Idempotent shutdown initiation
  • LIFO hook execution
  • Shutdown reason tracking
  • Context-based cancellation propagation

func NewShutdown

func NewShutdown() *Shutdown

NewShutdown creates a new shutdown coordinator.

The returned coordinator is ready to use and can be shared across multiple GRIP components:

sd := lifecycle.NewShutdown()
u := unary.New(unary.WithShutdown(sd))
s := serverstream.New(serverstream.WithShutdown(sd))

type ShutdownHook

type ShutdownHook = lifecycle.ShutdownHook

ShutdownHook is a function called during shutdown. Hooks are executed in LIFO order.

Jump to

Keyboard shortcuts

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