finalizer

package
v1.25.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FinalizerAlreadyDoneErr = errors.New("finalizer already finalized")
	FinalizerUnknownIdErr   = errors.New("finalizer callback not found")
	FinalizerDuplicateIdErr = errors.New("finalizer callback already registered")
)

Functions

This section is empty.

Types

type Finalizer

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

func New

func New(
	logger log.Logger,
	metricsHandler metrics.Handler,
) *Finalizer

func (*Finalizer) Deregister

func (f *Finalizer) Deregister(
	id string,
) (err error)

Deregister removes a callback from the finalizer. Returns an error if the ID is not found, or when the finalizer is/was already running.

func (*Finalizer) Register

func (f *Finalizer) Register(
	id string,
	callback func(context.Context) error,
) error

Register adds a callback to the finalizer. Returns an error if the ID is already registered, or when the finalizer is/was already running.

func (*Finalizer) Run

func (f *Finalizer) Run(
	timeout time.Duration,
) int

Run executes all registered callback functions within the given timeout (zero timeout skips execution). It can only be invoked once; calling it again has no effect. Returns the number of completed callbacks.

Jump to

Keyboard shortcuts

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