exitcleanup

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package exitcleanup provides helpers for running cleanups when the program is interrupted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExitCleaner added in v0.1.3

type ExitCleaner interface {
	ToContext(ctx context.Context) context.Context
	Register(fn func() error)
}

type ExitCleanup

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

ExitCleanup supports registering functions to be called when the program is interrupted.

func New

func New(log *log.Logger) (*ExitCleanup, func())

New creates an ExitCleanup. It returns a cleanup function that should be called once right before exiting the app.

func (*ExitCleanup) Register

func (cleanup *ExitCleanup) Register(fn func() error)

Register a callback cleanup function.

func (*ExitCleanup) ToContext added in v0.1.3

func (cleanup *ExitCleanup) ToContext(ctx context.Context) context.Context

ToContext adds the ability to cancel the context. It should be used to wrap any contexts that are passed to functions that leverage Register().

Jump to

Keyboard shortcuts

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