summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/segmentio/backo-go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/segmentio/backo-go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/segmentio/backo-go')
-rw-r--r--vendor/github.com/segmentio/backo-go/backo_test.go77
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore7
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md45
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go76
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go15
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go5
-rw-r--r--vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go13
7 files changed, 0 insertions, 238 deletions
diff --git a/vendor/github.com/segmentio/backo-go/backo_test.go b/vendor/github.com/segmentio/backo-go/backo_test.go
deleted file mode 100644
index 89933acf7..000000000
--- a/vendor/github.com/segmentio/backo-go/backo_test.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package backo
-
-import (
- "fmt"
- "math"
- "testing"
- "time"
-
- "github.com/bmizerany/assert"
-)
-
-// Tests default backo behaviour.
-func TestDefaults(t *testing.T) {
- backo := DefaultBacko()
-
- assert.Equal(t, milliseconds(100), backo.Duration(0))
- assert.Equal(t, milliseconds(200), backo.Duration(1))
- assert.Equal(t, milliseconds(400), backo.Duration(2))
- assert.Equal(t, milliseconds(800), backo.Duration(3))
-}
-
-// Tests backo does not exceed cap.
-func TestCap(t *testing.T) {
- backo := NewBacko(milliseconds(100), 2, 0, milliseconds(600))
-
- assert.Equal(t, milliseconds(100), backo.Duration(0))
- assert.Equal(t, milliseconds(200), backo.Duration(1))
- assert.Equal(t, milliseconds(400), backo.Duration(2))
- assert.Equal(t, milliseconds(600), backo.Duration(3))
-}
-
-// Tests that jitter adds randomness.
-func TestJitter(t *testing.T) {
- defaultBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
- jitterBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
-
- // TODO: Check jittered durations are within a range.
- assert.NotEqual(t, jitterBacko.Duration(0), defaultBacko.Duration(0))
- assert.NotEqual(t, jitterBacko.Duration(1), defaultBacko.Duration(1))
- assert.NotEqual(t, jitterBacko.Duration(2), defaultBacko.Duration(2))
- assert.NotEqual(t, jitterBacko.Duration(3), defaultBacko.Duration(3))
-}
-
-func ExampleBacko_BackoffDefault() {
- b := DefaultBacko()
- ticker := b.NewTicker()
-
- for i := 0; i < 6; i++ {
- start := time.Now()
- select {
- case t := <-ticker.C:
- fmt.Println(nearest10Millis(t.Sub(start)))
- }
- }
-
- ticker.Stop()
-
- // Output:
- // 100
- // 200
- // 400
- // 800
- // 1600
- // 3200
-}
-
-func nearest10Millis(d time.Duration) float64 {
- // Typically d is something like 11 or 21, so do some magic to round the
- // durations to the nearest 10. We divide d by 10, floor it, and multiply it
- // by 10 again.
- return math.Floor(float64(d/time.Millisecond/10) * 10)
-}
-
-// Returns the given milliseconds as time.Duration
-func milliseconds(ms int64) time.Duration {
- return time.Duration(ms * 1000 * 1000)
-}
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore
deleted file mode 100644
index b6fadf4eb..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-_go_.*
-_gotest_.*
-_obj
-_test
-_testmain.go
-*.out
-*.[568]
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md
deleted file mode 100644
index 8b6b6fc4f..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Assert (c) Blake Mizerany and Keith Rarick -- MIT LICENCE
-
-## Assertions for Go tests
-
-## Install
-
- $ go get github.com/bmizerany/assert
-
-## Use
-
-**point.go**
-
- package point
-
- type Point struct {
- x, y int
- }
-
-**point_test.go**
-
-
- package point
-
- import (
- "testing"
- "github.com/bmizerany/assert"
- )
-
- func TestAsserts(t *testing.T) {
- p1 := Point{1, 1}
- p2 := Point{2, 1}
-
- assert.Equal(t, p1, p2)
- }
-
-**output**
- $ go test
- --- FAIL: TestAsserts (0.00 seconds)
- assert.go:15: /Users/flavio.barbosa/dev/stewie/src/point_test.go:12
- assert.go:24: ! X: 1 != 2
- FAIL
-
-## Docs
-
- http://github.com/bmizerany/assert
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go
deleted file mode 100644
index 7409f985e..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package assert
-// Testing helpers for doozer.
-
-import (
- "github.com/kr/pretty"
- "reflect"
- "testing"
- "runtime"
- "fmt"
-)
-
-func assert(t *testing.T, result bool, f func(), cd int) {
- if !result {
- _, file, line, _ := runtime.Caller(cd + 1)
- t.Errorf("%s:%d", file, line)
- f()
- t.FailNow()
- }
-}
-
-func equal(t *testing.T, exp, got interface{}, cd int, args ...interface{}) {
- fn := func() {
- for _, desc := range pretty.Diff(exp, got) {
- t.Error("!", desc)
- }
- if len(args) > 0 {
- t.Error("!", " -", fmt.Sprint(args...))
- }
- }
- result := reflect.DeepEqual(exp, got)
- assert(t, result, fn, cd+1)
-}
-
-func tt(t *testing.T, result bool, cd int, args ...interface{}) {
- fn := func() {
- t.Errorf("! Failure")
- if len(args) > 0 {
- t.Error("!", " -", fmt.Sprint(args...))
- }
- }
- assert(t, result, fn, cd+1)
-}
-
-func T(t *testing.T, result bool, args ...interface{}) {
- tt(t, result, 1, args...)
-}
-
-func Tf(t *testing.T, result bool, format string, args ...interface{}) {
- tt(t, result, 1, fmt.Sprintf(format, args...))
-}
-
-func Equal(t *testing.T, exp, got interface{}, args ...interface{}) {
- equal(t, exp, got, 1, args...)
-}
-
-func Equalf(t *testing.T, exp, got interface{}, format string, args ...interface{}) {
- equal(t, exp, got, 1, fmt.Sprintf(format, args...))
-}
-
-func NotEqual(t *testing.T, exp, got interface{}, args ...interface{}) {
- fn := func() {
- t.Errorf("! Unexpected: <%#v>", exp)
- if len(args) > 0 {
- t.Error("!", " -", fmt.Sprint(args...))
- }
- }
- result := !reflect.DeepEqual(exp, got)
- assert(t, result, fn, 1)
-}
-
-func Panic(t *testing.T, err interface{}, fn func()) {
- defer func() {
- equal(t, err, recover(), 3)
- }()
- fn()
-}
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go
deleted file mode 100644
index 162a590c6..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/assert_test.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package assert
-
-import (
- "testing"
-)
-
-func TestLineNumbers(t *testing.T) {
- Equal(t, "foo", "foo", "msg!")
- //Equal(t, "foo", "bar", "this should blow up")
-}
-
-func TestNotEqual(t *testing.T) {
- NotEqual(t, "foo", "bar", "msg!")
- //NotEqual(t, "foo", "foo", "this should blow up")
-}
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go
deleted file mode 100644
index 15789fe10..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package point
-
-type Point struct {
- X, Y int
-}
diff --git a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go b/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go
deleted file mode 100644
index 34e791a43..000000000
--- a/vendor/github.com/segmentio/backo-go/vendor/github.com/bmizerany/assert/example/point_test.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package point
-
-import (
- "testing"
- "assert"
-)
-
-func TestAsserts(t *testing.T) {
- p1 := Point{1, 1}
- p2 := Point{2, 1}
-
- assert.Equal(t, p1, p2)
-}