diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-04-16 05:37:14 -0700 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-16 08:37:14 -0400 |
commit | 6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch) | |
tree | 3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/github.com/olivere/elastic/retry.go | |
parent | bf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff) | |
download | chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2 chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip |
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/github.com/olivere/elastic/retry.go')
-rw-r--r-- | vendor/github.com/olivere/elastic/retry.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/vendor/github.com/olivere/elastic/retry.go b/vendor/github.com/olivere/elastic/retry.go deleted file mode 100644 index 3571a3b7a..000000000 --- a/vendor/github.com/olivere/elastic/retry.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012-present Oliver Eilhard. All rights reserved. -// Use of this source code is governed by a MIT-license. -// See http://olivere.mit-license.org/license.txt for details. - -// This file is based on code (c) 2014 Cenk Altı and governed by the MIT license. -// See https://github.com/cenkalti/backoff for original source. - -package elastic - -import "time" - -// An Operation is executing by Retry() or RetryNotify(). -// The operation will be retried using a backoff policy if it returns an error. -type Operation func() error - -// Notify is a notify-on-error function. It receives error returned -// from an operation. -// -// Notice that if the backoff policy stated to stop retrying, -// the notify function isn't called. -type Notify func(error) - -// Retry the function f until it does not return error or BackOff stops. -// f is guaranteed to be run at least once. -// It is the caller's responsibility to reset b after Retry returns. -// -// Retry sleeps the goroutine for the duration returned by BackOff after a -// failed operation returns. -func Retry(o Operation, b Backoff) error { return RetryNotify(o, b, nil) } - -// RetryNotify calls notify function with the error and wait duration -// for each failed attempt before sleep. -func RetryNotify(operation Operation, b Backoff, notify Notify) error { - var err error - var wait time.Duration - var retry bool - var n int - - for { - if err = operation(); err == nil { - return nil - } - - n++ - wait, retry = b.Next(n) - if !retry { - return err - } - - if notify != nil { - notify(err) - } - - time.Sleep(wait) - } -} |