diff --git a/limiter/interface.go b/limiter/interface.go index aa9df3fe4..f089ca1d0 100644 --- a/limiter/interface.go +++ b/limiter/interface.go @@ -2,8 +2,11 @@ package limiter import ( "context" + "errors" ) +var ErrTimeout = errors.New("timeout exceeded") + type ServerLimiter interface { Capacity() int Enter(ctx context.Context, s string) error diff --git a/limiter/limiter.go b/limiter/limiter.go index 6408b286a..f81853d8a 100644 --- a/limiter/limiter.go +++ b/limiter/limiter.go @@ -2,7 +2,6 @@ package limiter import ( "context" - "errors" ) // ServerLimiter provides interface to limit amount of requests @@ -44,7 +43,7 @@ func (sl RealLimiter) Enter(ctx context.Context, s string) error { case sl.m[s] <- struct{}{}: return nil case <-ctx.Done(): - return errors.New("timeout exceeded") + return ErrTimeout } }