From 524fb01f904efc67f853a079e882f2145e927a2d Mon Sep 17 00:00:00 2001 From: Matias <83959431+mativm02@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:59:29 -0300 Subject: [PATCH] linting --- main.go | 10 +++++----- storage/redis.go | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index a1e357ccf..04804dbb5 100644 --- a/main.go +++ b/main.go @@ -223,6 +223,7 @@ func StartPurgeLoop(wg *sync.WaitGroup, ctx context.Context, secInterval int, ch log.WithFields(logrus.Fields{ "prefix": mainPrefix, }).Error("Error trying to execute GetAndDeleteSet: " + err.Error()) + return } if len(AnalyticsValues) > 0 { PreprocessAnalyticsValues(AnalyticsValues, serializerMethod, analyticsKeyName, omitDetails, job, startTime, secInterval) @@ -236,11 +237,10 @@ func StartPurgeLoop(wg *sync.WaitGroup, ctx context.Context, secInterval int, ch if !SystemConfig.DontPurgeUptimeData { UptimeValues, err := UptimeStorage.GetAndDeleteSet(storage.UptimeAnalytics_KEYNAME, chunkSize, expire) if err != nil { - if err != nil { - log.WithFields(logrus.Fields{ - "prefix": mainPrefix, - }).Error("Error trying to execute GetAndDeleteSet: " + err.Error()) - } + log.WithFields(logrus.Fields{ + "prefix": mainPrefix, + }).Error("Error trying to execute GetAndDeleteSet: " + err.Error()) + return } UptimePump.WriteUptimeData(UptimeValues) } diff --git a/storage/redis.go b/storage/redis.go index 5b3a56e4a..511fb8cd7 100644 --- a/storage/redis.go +++ b/storage/redis.go @@ -19,12 +19,14 @@ import ( // ------------------- REDIS CLUSTER STORAGE MANAGER ------------------------------- -var redisClusterSingleton *redisManager -var redisLogPrefix = "redis" -var ENV_REDIS_PREFIX = "TYK_PMP_REDIS" -var ctx = context.Background() +var ( + redisClusterSingleton *RedisManager + redisLogPrefix = "redis" + ENV_REDIS_PREFIX = "TYK_PMP_REDIS" + ctx = context.Background() +) -type redisManager struct { +type RedisManager struct { list list.List kv keyvalue.KeyValue conn model.Connector @@ -87,13 +89,13 @@ type RedisStorageConfig struct { // RedisClusterStorageManager is a storage manager that uses the redis database. type RedisClusterStorageManager struct { - db *redisManager + db *RedisManager KeyPrefix string HashKeys bool Config RedisStorageConfig } -func NewRedisClusterPool(forceReconnect bool, config *RedisStorageConfig) *redisManager { +func NewRedisClusterPool(forceReconnect bool, config *RedisStorageConfig) *RedisManager { if !forceReconnect { if redisClusterSingleton != nil { log.WithFields(logrus.Fields{ @@ -164,7 +166,7 @@ func NewRedisClusterPool(forceReconnect bool, config *RedisStorageConfig) *redis return nil } - redisClusterSingleton = &redisManager{} + redisClusterSingleton = &RedisManager{} redisClusterSingleton.kv = kv redisClusterSingleton.list = l @@ -284,7 +286,6 @@ func (r *RedisClusterStorageManager) GetAndDeleteSet(keyName string, chunkSize i intResult := []interface{}{} for _, v := range result { intResult = append(intResult, v) - } return intResult, nil