Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 26-Mar-2018 | - | ||||
README.md | H A D | 26-Mar-2018 | 858 | 28 | 21 | |
deadline.go | H A D | 26-Mar-2018 | 1.3 KiB | 46 | 28 | |
deadline_test.go | H A D | 26-Mar-2018 | 1.1 KiB | 66 | 49 |
README.md
1deadline 2======== 3 4[![Build Status](https://travis-ci.org/eapache/go-resiliency.svg?branch=master)](https://travis-ci.org/eapache/go-resiliency) 5[![GoDoc](https://godoc.org/github.com/eapache/go-resiliency/deadline?status.svg)](https://godoc.org/github.com/eapache/go-resiliency/deadline) 6[![Code of Conduct](https://img.shields.io/badge/code%20of%20conduct-active-blue.svg)](https://eapache.github.io/conduct.html) 7 8The deadline/timeout resiliency pattern for golang. 9 10Creating a deadline takes one parameter: how long to wait. 11 12```go 13dl := deadline.New(1 * time.Second) 14 15err := dl.Run(func(stopper <-chan struct{}) error { 16 // do something potentially slow 17 // give up when the `stopper` channel is closed (indicating a time-out) 18 return nil 19}) 20 21switch err { 22case deadline.ErrTimedOut: 23 // execution took too long, oops 24default: 25 // some other error 26} 27``` 28