lifecycle

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles graceful cleanup of resources with error aggregation. This consolidates the defer Close() pattern used across cmd/server/main.go and pkg/cedros/app.go.

func NewManager

func NewManager() *Manager

NewManager creates a new resource lifecycle manager.

func (*Manager) Close

func (m *Manager) Close() error

Close closes all registered resources in reverse order. It aggregates all errors and logs them, returning the first error encountered. This ensures all cleanup attempts are made even if some fail.

func (*Manager) Register

func (m *Manager) Register(name string, closer io.Closer)

Register adds a resource to be closed when the manager is closed. Resources are closed in reverse order of registration (LIFO).

func (*Manager) RegisterFunc

func (m *Manager) RegisterFunc(name string, fn func() error)

RegisterFunc wraps a cleanup function as a Closer for convenience.

Jump to

Keyboard shortcuts

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