cleanup

package
v0.112.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTeardown = errors.New("teardown failed")

ErrTeardown is wrapped into every error Run returns, so a caller that tolerates another error in the same chain (for example the cancellation that aborted a startup) can still tell that a cleanup fn failed.

Functions

func OnlyCancelled added in v0.112.11

func OnlyCancelled(err error) bool

OnlyCancelled reports whether err is nil, or contains context.Canceled without ErrTeardown. It does not establish where the cancellation came from or exclude other errors in the same tree. A caller that joins Run's error to the cancellation it requested uses it in place of errors.Is, which would accept the tree even when a cleanup fn failed.

Types

type Cleanup

type Cleanup struct {
	Fns       []CleanupFn
	TimeLimit time.Duration
	// contains filtered or unexported fields
}

func New

func New(logger *zerolog.Logger) Cleanup

func (*Cleanup) Add

func (c *Cleanup) Add(fn func() error, name string)

func (*Cleanup) Run

func (c *Cleanup) Run() error

type CleanupFn

type CleanupFn struct {
	Fn   func() error
	Name string
}

Jump to

Keyboard shortcuts

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