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 ¶
Types ¶
type Forever ¶
type Forever struct {
// contains filtered or unexported fields
}
Forever encapsulates logic to run a function forever.
func NewForever ¶
NewForever creates a new Forever struct. The given duration controls how long retry of a function should be delayed if the function were to thrown an error.
func (*Forever) Go ¶
func (f *Forever) Go(fn func())
Go 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.