finalizer

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextCloser

func NewContextCloser(cancel context.CancelFunc) io.Closer

NewContextCloser transforms context cancellation function to be used with finalizer.

Types

type ContextCloser

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

ContextCloser maps a context to io.Closer.

func (ContextCloser) Close

func (cc ContextCloser) Close() error

Close the context.

type Finalizer

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

Finalizer collects resources for convenient cleanup.

func NewFinalizer

func NewFinalizer() *Finalizer

NewFinalizer returns a new Finalizer.

func (*Finalizer) Add

func (r *Finalizer) Add(cs ...io.Closer)

Add one or more io.Closer to the finalizer.

func (*Finalizer) AddFn

func (r *Finalizer) AddFn(fs ...func())

AddFn one or more func() to the finalizer.

func (*Finalizer) Cleanup

func (r *Finalizer) Cleanup(err error) error

Cleanup closes all io.Closer and cancels all contexts with err.

func (*Finalizer) Cleanupf

func (r *Finalizer) Cleanupf(format string, err error) error

Cleanupf closes all io.Closer and cancels all contexts with a formatted err.

Jump to

Keyboard shortcuts

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