lifecycle

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package lifecycle provides a minimal orchestration primitive for running concurrent components that share a single context for cancellation and graceful shutdown via OS signals.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, args ...any) error

Run orchestrates one or more components. It accepts Component values (or bare func(ctx context.Context) error). It creates a context cancelled on SIGTERM or SIGINT, launches every component as a goroutine in an errgroup, and waits for all of them to finish. If any component returns an error the shared context is cancelled, signalling the remaining components to shut down. The first non-nil error (if any) is returned.

Types

type Component

type Component func(ctx context.Context) error

Component is a long-running function that participates in the application lifecycle. It must respect ctx.Done() to allow graceful shutdown.

Jump to

Keyboard shortcuts

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