diff options
author | Chris Wendt <chrismwendt@gmail.com> | 2022-06-08 03:18:43 -0600 |
---|---|---|
committer | Chris Wendt <chrismwendt@gmail.com> | 2022-06-08 03:18:43 -0600 |
commit | a7900ffa1ba5655a5fad903c6634c888d3025d86 (patch) | |
tree | acf1109fc14aba8578b1972bfd6a477842f5e2e0 /rate/ratelimit.go | |
parent | remove unreachable code (diff) | |
download | stm-a7900ffa1ba5655a5fad903c6634c888d3025d86.tar.gz stm-a7900ffa1ba5655a5fad903c6634c888d3025d86.tar.xz |
eliminate some type assertions
Diffstat (limited to 'rate/ratelimit.go')
-rw-r--r-- | rate/ratelimit.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/rate/ratelimit.go b/rate/ratelimit.go index 6645e04..f521f66 100644 --- a/rate/ratelimit.go +++ b/rate/ratelimit.go @@ -77,9 +77,9 @@ func (rl *Limiter) Allow() bool { } func (rl *Limiter) AllowN(n numTokens) bool { - return stm.Atomically(func(tx *stm.Tx) interface{} { + return stm.Atomically(func(tx *stm.Tx) bool { return rl.takeTokens(tx, n) - }).(bool) + }) } func (rl *Limiter) AllowStm(tx *stm.Tx) bool { @@ -105,7 +105,7 @@ func (rl *Limiter) Wait(ctx context.Context) error { func (rl *Limiter) WaitN(ctx context.Context, n int) error { ctxDone, cancel := stmutil.ContextDoneVar(ctx) defer cancel() - if err := stm.Atomically(func(tx *stm.Tx) interface{} { + if err := stm.Atomically(func(tx *stm.Tx) error { if ctxDone.Get(tx) { return ctx.Err() } @@ -123,7 +123,7 @@ func (rl *Limiter) WaitN(ctx context.Context, n int) error { tx.Retry() panic("unreachable") }); err != nil { - return err.(error) + return err } return nil |