mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-17 09:25:11 +00:00
refactor: Replace interface{} with any type alias across codebase
- Replace interface{} with any in api_integration_test.go makeRequest method and test response maps
- Replace interface{} with any in logging.go WithField method and all logging function signatures
- Replace interface{} with any in middleware etag.go sync.Map.Range callback
- Replace interface{} with any in middleware redis_ratelimit.go RedisClientInterface and result parsing
- Replace interface{} with any in middleware redis_ratelimit_
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
// RedisClientInterface defines the interface for Redis operations
|
||||
type RedisClientInterface interface {
|
||||
Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
|
||||
Eval(ctx context.Context, script string, keys []string, args ...any) *redis.Cmd
|
||||
Del(ctx context.Context, keys ...string) *redis.IntCmd
|
||||
ZCount(ctx context.Context, key, min, max string) *redis.IntCmd
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func (r *RedisRateLimiter) Allow(ctx context.Context, key string) (*RateLimitRes
|
||||
}
|
||||
|
||||
// Parse Lua script result
|
||||
resultSlice, ok := result.([]interface{})
|
||||
resultSlice, ok := result.([]any)
|
||||
if !ok || len(resultSlice) < 3 {
|
||||
return nil, fmt.Errorf("invalid redis result format")
|
||||
}
|
||||
@@ -163,7 +163,7 @@ func (r *RedisRateLimiter) AllowTokenBucket(ctx context.Context, key string) (*R
|
||||
return nil, fmt.Errorf("redis token bucket check failed: %w", err)
|
||||
}
|
||||
|
||||
resultSlice, ok := result.([]interface{})
|
||||
resultSlice, ok := result.([]any)
|
||||
if !ok || len(resultSlice) < 3 {
|
||||
return nil, fmt.Errorf("invalid redis result format")
|
||||
}
|
||||
@@ -207,10 +207,7 @@ func (r *RedisRateLimiter) GetStats(ctx context.Context, key string) (*RateLimit
|
||||
return nil, fmt.Errorf("failed to get rate limit stats: %w", err)
|
||||
}
|
||||
|
||||
remaining := r.limit - int64(count)
|
||||
if remaining < 0 {
|
||||
remaining = 0
|
||||
}
|
||||
remaining := max(r.limit-int64(count), 0)
|
||||
|
||||
return &RateLimitResult{
|
||||
Allowed: remaining > 0,
|
||||
|
||||
Reference in New Issue
Block a user