Skip to content

Commit 51616b5

Browse files
committed
fix rate limiter concurrency test
1 parent e826318 commit 51616b5

File tree

3 files changed

+494
-364
lines changed

3 files changed

+494
-364
lines changed

pkg/gofr/service/rate_limiter_distributed.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ return {allowed, retryAfter}
5858
// distributedRateLimiter with metrics support.
5959
type distributedRateLimiter struct {
6060
config RateLimiterConfig
61-
redisClient gofrRedis.Redis
61+
redisClient *gofrRedis.Redis
6262
logger Logger
6363
metrics Metrics
6464
HTTP
@@ -69,12 +69,16 @@ func NewDistributedRateLimiter(config RateLimiterConfig, h HTTP) HTTP {
6969

7070
rl := &distributedRateLimiter{
7171
config: config,
72-
redisClient: *config.RedisClient,
72+
redisClient: config.RedisClient,
7373
logger: httpSvc.Logger,
7474
metrics: httpSvc.Metrics,
7575
HTTP: h,
7676
}
7777

78+
if rl.redisClient == nil {
79+
rl.logger.Log("Distributed rate limiter initialized without Redis client; operating pass-through")
80+
}
81+
7882
return rl
7983
}
8084

0 commit comments

Comments
 (0)