mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 02:07:58 +00:00
Add vendor folder to git
This commit is contained in:
parent
66cf5eaafb
commit
183585f56f
6916 changed files with 2629581 additions and 1 deletions
15
vendor/github.com/coreos/pkg/timeutil/backoff.go
generated
vendored
Normal file
15
vendor/github.com/coreos/pkg/timeutil/backoff.go
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package timeutil
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func ExpBackoff(prev, max time.Duration) time.Duration {
|
||||
if prev == 0 {
|
||||
return time.Second
|
||||
}
|
||||
if prev > max/2 {
|
||||
return max
|
||||
}
|
||||
return 2 * prev
|
||||
}
|
||||
52
vendor/github.com/coreos/pkg/timeutil/backoff_test.go
generated
vendored
Normal file
52
vendor/github.com/coreos/pkg/timeutil/backoff_test.go
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package timeutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestExpBackoff(t *testing.T) {
|
||||
tests := []struct {
|
||||
prev time.Duration
|
||||
max time.Duration
|
||||
want time.Duration
|
||||
}{
|
||||
{
|
||||
prev: time.Duration(0),
|
||||
max: time.Minute,
|
||||
want: time.Second,
|
||||
},
|
||||
{
|
||||
prev: time.Second,
|
||||
max: time.Minute,
|
||||
want: 2 * time.Second,
|
||||
},
|
||||
{
|
||||
prev: 16 * time.Second,
|
||||
max: time.Minute,
|
||||
want: 32 * time.Second,
|
||||
},
|
||||
{
|
||||
prev: 32 * time.Second,
|
||||
max: time.Minute,
|
||||
want: time.Minute,
|
||||
},
|
||||
{
|
||||
prev: time.Minute,
|
||||
max: time.Minute,
|
||||
want: time.Minute,
|
||||
},
|
||||
{
|
||||
prev: 2 * time.Minute,
|
||||
max: time.Minute,
|
||||
want: time.Minute,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
got := ExpBackoff(tt.prev, tt.max)
|
||||
if tt.want != got {
|
||||
t.Errorf("case %d: want=%v got=%v", i, tt.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue