lifecycle

package
v0.1.28 Latest Latest
Warning

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

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

Documentation

Overview

Package lifecycle provides application lifecycle management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterShutdownListener

func RegisterShutdownListener(
	shutdownlistener *internalhelper.ShutdownListener,
	lifecycle fx.Lifecycle,
)

RegisterShutdownListener registers the shutdown listener in the lifecycle.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor is a struct that schedules and manages the execution of runners. It uses a WaitGroup to wait for all runners to finish before stopping.

func NewExecutor

func NewExecutor(
	lifecycle fx.Lifecycle,
	runners []Runner,
	logger *slog.Logger,
) *Executor

NewExecutor creates a new Executor instance.

type Runner

type Runner interface {
	// Name returns the name of the runner.
	// It's only for debugging & logging purposes.
	Name() string

	// Run starts the runner with the given context.
	Run(ctx context.Context) error
}

Runner is an interface that defines a runner that can be started with a context.

Jump to

Keyboard shortcuts

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