Skip to content

Commit

Permalink
feat: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hokamsingh committed Aug 28, 2024
1 parent dd5e901 commit aad503e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/core/middleware/ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package middleware

import (
"context"
"log"
"net/http"
"strconv"
"sync"
Expand Down Expand Up @@ -79,10 +80,15 @@ func NewRateLimiter(limiterType RateLimiterType, config interface{}) *RateLimite
return rl

case RedisBacked:
ctx := context.Background()
cfg := config.(RedisConfig)
client := redis.NewClient(&redis.Options{
Addr: cfg.Addr,
})
_, err := client.Ping(ctx).Result()
if err != nil {
log.Fatalf("Could not connect to Redis: %v", err)
}
return &RateLimiter{
limiterType: RedisBacked,
limit: cfg.Limit,
Expand Down

0 comments on commit aad503e

Please sign in to comment.