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

..03-May-2022-

vendor/github.com/bmizerany/assert/H29-Jan-2020-

.gitmodulesH A D29-Jan-2020135

LICENSEH A D29-Jan-20201.1 KiB

README.mdH A D29-Jan-20202.3 KiB

backo.goH A D29-Jan-20201.7 KiB

backo_test.goH A D29-Jan-20202 KiB

go.modH A D29-Jan-202046

README.md

1Backo [![GoDoc](http://godoc.org/github.com/segmentio/backo-go?status.png)](http://godoc.org/github.com/segmentio/backo-go)
2-----
3
4Exponential backoff for Go (Go port of segmentio/backo).
5
6
7Usage
8-----
9
10```go
11import "github.com/segmentio/backo-go"
12
13// Create a Backo instance.
14backo := backo.NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
15// OR with defaults.
16backo := backo.DefaultBacko()
17
18// Use the ticker API.
19ticker := b.NewTicker()
20for {
21    timeout := time.After(5 * time.Minute)
22    select {
23    case  <-ticker.C:
24        fmt.Println("ticked")
25    case <- timeout:
26        fmt.Println("timed out")
27    }
28}
29
30// Or simply work with backoff intervals directly.
31for i := 0; i < n; i++ {
32    // Sleep the current goroutine.
33    backo.Sleep(i)
34    // Retrieve the duration manually.
35    duration := backo.Duration(i)
36}
37```
38
39License
40-------
41
42```
43WWWWWW||WWWWWW
44 W W W||W W W
45      ||
46    ( OO )__________
47     /  |           \
48    /o o|    MIT     \
49    \___/||_||__||_|| *
50         || ||  || ||
51        _||_|| _||_||
52       (__|__|(__|__|
53
54The MIT License (MIT)
55
56Copyright (c) 2015 Segment, Inc.
57
58Permission is hereby granted, free of charge, to any person obtaining a copy
59of this software and associated documentation files (the "Software"), to deal
60in the Software without restriction, including without limitation the rights
61to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62copies of the Software, and to permit persons to whom the Software is
63furnished to do so, subject to the following conditions:
64
65The above copyright notice and this permission notice shall be included in all
66copies or substantial portions of the Software.
67
68THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
74SOFTWARE.
75```
76
77
78
79 [1]: http://github.com/segmentio/backo-java
80 [2]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.segment.backo&a=backo&v=LATEST