reject logout on empty providers
This commit is contained in:
Generated
+3
-3
@@ -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"
|
||||
|
||||
+1
-3
@@ -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
|
||||
|
||||
+2
-3
@@ -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()`
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
+13
-1
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user