cleanup

package
v0.0.0-...-8ed7812 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtExit

func AtExit(fn func())

AtExit runs the given function before the program exits, either naturally, or when a signal is received. In order to run the function on normal exit, Cleanup() should be called at the end of main(). common.Defer() is the canonical way to do this.

func Cleanup

func Cleanup()

Cleanup cancels all tick functions registered via Repeat(), then waits for them to fully stop running and for their cleanup functions to run. Cleanup() runs automatically when SIGINT or SIGTERM is received. If your program runs interactively or is expected to exit normally under other circumstances, you should make sure Cleanup() is called at the end of main(). common.Defer() is the canonical way to do this.

func Disable

func Disable()

Disable signal handling for the cleanup package.

func Enable

func Enable()

Enable signal handling for the cleanup package.

func Repeat

func Repeat(tickFrequency time.Duration, tick func(context.Context), cleanup func())

Repeat runs the tick function immediately and on the given timer. When Cancel() is called, waits for any active tick() to finish (tick may or may not respect ctx.Done), and then the optional cleanup function is run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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