• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..26-Mar-2018-

README.mdH A D26-Mar-2018858 2821

deadline.goH A D26-Mar-20181.3 KiB4628

deadline_test.goH A D26-Mar-20181.1 KiB6649

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