diff --git a/backend/Gopkg.lock b/backend/Gopkg.lock index 2b19bff7..5d3a5c1c 100644 --- a/backend/Gopkg.lock +++ b/backend/Gopkg.lock @@ -143,15 +143,15 @@ version = "v1.1.0" [[projects]] - digest = "1:0f24c72d7e9bcb682b907be0461ac552973cd4b3f1b60b04b725f6d74a3e59e7" + digest = "1:35cb9b5c59734ea9bc47166aabc7d7136139ed8fe39f084fbc29afbbe3ae9213" name = "github.com/go-pkgz/repeater" packages = [ ".", "strategy", ] pruneopts = "UT" - revision = "f2a67dcf050cab24d57132a7d8b45553ceab817b" - version = "v1.0.0" + revision = "661f2868dc41260f912f400aed01c14476659ff2" + version = "v1.1.1" [[projects]] digest = "1:9aba5c95373481f118e57e9740d9e82f86802d86849809ab89324bcb4f236451" diff --git a/backend/vendor/github.com/go-pkgz/repeater/.travis.yml b/backend/vendor/github.com/go-pkgz/repeater/.travis.yml index baf01e00..0d5a1c8b 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/.travis.yml +++ b/backend/vendor/github.com/go-pkgz/repeater/.travis.yml @@ -1,12 +1,10 @@ language: go go: - - "1.10.x" + - "1.11.x" go_import_path: github.com/go-pkgz/repeater -services: mongodb - before_install: - go get github.com/mattn/goveralls - go get gopkg.in/alecthomas/gometalinter.v2 diff --git a/backend/vendor/github.com/go-pkgz/repeater/README.md b/backend/vendor/github.com/go-pkgz/repeater/README.md index 8b04fc4e..76d8c906 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/README.md +++ b/backend/vendor/github.com/go-pkgz/repeater/README.md @@ -12,7 +12,7 @@ New Repeater created by `New(strtg strategy.Interface)` or shortcut for defaults To activate invoke `Do` method. `Do` repeats func until no error returned. Predefined (optional) errors terminates the loop immediately. -`func (r Repeater) Do(fun func() error, errors ...error) (err error)` +`func (r Repeater) Do(ctx context.Context, fun func() error, errors ...error) (err error)` ### Repeating strategy @@ -24,7 +24,7 @@ type Interface interface { } ``` -Returned channels used as "ticks," i.e., for each repeat or initial operation one read from this channel needed. Closing this channel indicates "done with retries." It is pretty much the same idea as `time.Timer` or `time.Tick` implements. Note - the first (technically not-repeated-yet) call won't happen **until something sent to the channel**. For this reason, the typical strategy sends first "tick" before the first wait/sleep. +Returned channels used as "ticks," i.e., for each repeat or initial operation one read from this channel needed. Closing this channel indicates "done with retries." It is pretty much the same idea as `time.Timer` or `time.Tick` implements. Note - the first (technically not-repeated-yet) call won't happen **until something sent to the channel**. For this reason, the typical strategy sends the first "tick" before the first wait/sleep. Three most common strategies provided by package and ready to use: 1. **Fixed delay**, up to max number of attempts - `NewFixedDelay(repeats int, delay time.Duration)`. @@ -33,4 +33,3 @@ It is the default strategy used by `repeater.NewDefault` constructor 3. **Once** strategy does not do any repeats and mainly used for tests/mocks - `NewOnce()` - diff --git a/backend/vendor/github.com/go-pkgz/repeater/repeater.go b/backend/vendor/github.com/go-pkgz/repeater/repeater.go index c1721cb3..84dd0d47 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/repeater.go +++ b/backend/vendor/github.com/go-pkgz/repeater/repeater.go @@ -30,9 +30,9 @@ func NewDefault(repeats int, delay time.Duration) *Repeater { } // Do repeats fun till no error. Predefined (optional) errors terminate immediately -func (r Repeater) Do(fun func() error, errors ...error) (err error) { +func (r Repeater) Do(ctx context.Context, fun func() error, errors ...error) (err error) { - ctx, cancelFunc := context.WithCancel(context.Background()) + ctx, cancelFunc := context.WithCancel(ctx) defer cancelFunc() // ensure strategy's channel termination inErrors := func(err error) bool { diff --git a/backend/vendor/github.com/go-pkgz/repeater/strategy/backoff.go b/backend/vendor/github.com/go-pkgz/repeater/strategy/backoff.go index 0f5b8013..839a3e23 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/strategy/backoff.go +++ b/backend/vendor/github.com/go-pkgz/repeater/strategy/backoff.go @@ -47,7 +47,7 @@ func (b *Backoff) Start(ctx context.Context) (ch chan struct{}) { if b.jitter { delay = rnd.Float64()*(float64(2*minDelay)) + (delay - float64(minDelay)) } - time.Sleep(time.Duration(delay)) + sleep(ctx, time.Duration(delay)) } } }() diff --git a/backend/vendor/github.com/go-pkgz/repeater/strategy/fixed.go b/backend/vendor/github.com/go-pkgz/repeater/strategy/fixed.go index adcef013..b92428d2 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/strategy/fixed.go +++ b/backend/vendor/github.com/go-pkgz/repeater/strategy/fixed.go @@ -33,7 +33,7 @@ func (s *FixedDelay) Start(ctx context.Context) (ch chan struct{}) { return default: ch <- struct{}{} - time.Sleep(s.delay) + sleep(ctx, s.delay) } } }() diff --git a/backend/vendor/github.com/go-pkgz/repeater/strategy/strategy.go b/backend/vendor/github.com/go-pkgz/repeater/strategy/strategy.go index 5ebb5ebb..f95e31de 100644 --- a/backend/vendor/github.com/go-pkgz/repeater/strategy/strategy.go +++ b/backend/vendor/github.com/go-pkgz/repeater/strategy/strategy.go @@ -2,7 +2,10 @@ // Strategy result is a channel acting like time.Timer ot time.Tick package strategy -import "context" +import ( + "context" + "time" +) // Interface for repeater strategy. Returns channel with ticks type Interface interface { @@ -26,3 +29,12 @@ func (s *Once) Start(ctx context.Context) (ch chan struct{}) { }() return ch } + +func sleep(ctx context.Context, duration time.Duration) { + select { + case <-time.After(duration): + return + case <-ctx.Done(): + return + } +}