diff --git a/limiter.go b/limiter.go index 97920ad..045e6a0 100644 --- a/limiter.go +++ b/limiter.go @@ -30,10 +30,9 @@ func newLimiter(origFactory observerFactory, limit int64, block bool) observerFa } } return func(ctx context.Context) (observer, error) { - if sem.TryAcquire(1) { - return wrappedFactory(ctx) - } else { + if !sem.TryAcquire(1) { return nil, ErrConcurrencyLimitReached } + return wrappedFactory(ctx) } }