dontpanic

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package dontpanic provides function wrappers and supervisors to ensure that wrapped code does not panic and cause program crashes.

When should you use this package? Anytime you are running a function or goroutine where it isn't obvious whether it can or can't panic. This may be a higher risk in long running goroutines and functions or ones that are difficult to test completely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(fn func())

Go will run the provided function in a goroutine and recover from any panics. If a panic occurs, the recovered panic will be sent to Sentry and logged as an error. Go is best used in fire-and-forget goroutines where observability is lost.

func GoForever

func GoForever(backoff time.Duration, fn func())

GoForever will keep retrying a function fn in a goroutine forever in the background (until the process exits) while recovering from panics. Each time a closure panics, the recovered value will be sent to Sentry and logged at level error. The provided backoff will delay retries to enable "breathing" room to prevent potentially worsening the situation.

func Try

func Try(fn func())

Try will wrap the provided function with a panic recovery. If a panic occurs, the recovered panic will be sent to Sentry and logged as an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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