work

package
v0.0.0-...-ded32d3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorHandlers = []func(error){
	logError,
	(&rudimentaryErrorBackoff{
		lastErrorTime: time.Now(),
		minPeriod:     time.Millisecond,
	}).OnError,
}

ErrorHandlers is a list of functions which will be invoked when an unreturnable error occurs.

View Source
var PanicHandlers = []func(interface{}){logPanic}

PanicHandlers is a list of functions which will be invoked when a panic happens.

View Source
var (
	// ReallyCrash controls the behavior of HandleCrash and now defaults
	// true. It's still exposed so components can optionally set to false
	// to restore prior behavior.
	ReallyCrash = true
)

Functions

func GetCaller

func GetCaller() string

GetCaller returns the caller of the function that calls it.

func HandleCrash

func HandleCrash(additionalHandlers ...func(interface{}))

HandleCrash simply catches a crash and logs an error. Meant to be called via defer. Additional context-specific handlers can be provided, and will be called in case of panic. HandleCrash actually crashes, after calling the handlers and logging the panic message.

func HandleError

func HandleError(err error)

HandlerError is a method to invoke when a non-user facing piece of code cannot return an error and needs to indicate it has been ignored. Invoking this method is preferable to logging the error - the default behavior is to log but the errors may be sent to a remote server for analysis.

func Parallelize

func Parallelize(workers, pieces int, doWorkPiece DoWorkPieceFunc)

Parallelize is a very simple framework that allow for parallelizing N independent pieces of work.

func RecoverFromPanic

func RecoverFromPanic(err *error)

RecoverFromPanic replaces the specified error with an error containing the original error, and the call tree when a panic occurs. This enables error handlers to handle errors and panics the same way.

Types

type DoWorkPieceFunc

type DoWorkPieceFunc func(piece int)

Jump to

Keyboard shortcuts

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