safely

package
v0.0.0-...-27e4b69 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(f func())

Go executes a supplied function and recovers from any panics that happen, logging those panics with a severity sufficient to push them to whatever error recording systems are registered as logrus hooks (i.e. bugsnag). It's meant to be called like: go safely.Go(...)

func Middleware

func Middleware(next http.Handler) http.Handler

func Recover

func Recover()

Recover recovers a panic, if any, and submits it to bugsnag through logrus (assuming that handler is registered) before terminating the program for real.

func Run

func Run(r Runnable)

func TombGo

func TombGo(t *tomb.Tomb, f func() error)

TombGo is the compose of Go and tomb.Go. Unlike Go though, the supplied function must return an error, because that's what tomb expects.

Types

type ErrPanicked

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

ErrPanicked is passed to bugsnag when we instrument a panic.

func (*ErrPanicked) Error

func (e *ErrPanicked) Error() string

type Runnable

type Runnable interface {
	// Tomb returns this Runnable's tomb used for lifecycle management.
	Tomb() *tomb.Tomb

	// Run begins the Runnable's main run loop.
	Run() error
}

Jump to

Keyboard shortcuts

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