status-go/vendor/github.com/eapache/go-resiliency/deadline
Victor Farazdagi 745c3a46c1 Updates vendors 2016-10-12 01:59:43 +03:00
..
README.md Updates vendors 2016-10-12 01:59:43 +03:00
deadline.go Updates vendors 2016-10-12 01:59:43 +03:00

README.md

deadline

Build Status GoDoc Code of Conduct

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 potentially slow
	// give up when the `stopper` channel is closed (indicating a time-out)
	return nil
})

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