Evan Huus cd85e9ecae Implement the deadline pattern hace 11 años
..
README.md cd85e9ecae Implement the deadline pattern hace 11 años
deadline.go cd85e9ecae Implement the deadline pattern hace 11 años
deadline_test.go cd85e9ecae Implement the deadline pattern hace 11 años

README.md

deadline

Build Status GoDoc

The deadline/timeout resiliency pattern for golang.

Creating a deadline takes one parameter: how long to wait.

dl := deadline.New(1 * time.Second)

err := dl.Run(func(stopper <-chan struct{}) error {
	// do something possibly slow
	// check stopper function and give up if timed out
	return nil
})

switch err {
case ErrTimedOut:
	// execution took too long, oops
default:
	// some other error
}