feat: Redis cluster support + version auto-detect + metrics API
This commit is contained in:
1 parent
8384006ae9
commit
3af65f2350
10 files changed
+485
-66
No files matched your search
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"time"
|
||||
"context"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"sql-platform/internal/middleware"
|
||||
"strings"
|
||||
"strconv"
|
||||
@@ -665,14 +664,6 @@ func executeSQLQuery(instance *model.Instance, dbName string, sqlStr string, lim
|
||||
}
|
||||
|
||||
func executeRedisQuery(instance *model.Instance, dbSelect string, command string, limit int, offset int) (gin.H, error) {
|
||||
password := instance.Password
|
||||
if strings.HasPrefix(password, "enc:") {
|
||||
decrypted, err := decryptPassword(strings.TrimPrefix(password, "enc:"))
|
||||
if err == nil {
|
||||
password = decrypted
|
||||
}
|
||||
}
|
||||
|
||||
// Parse Redis DB number from dbSelect (e.g. "0", "1")
|
||||
redisDB := 0
|
||||
if dbSelect != "" {
|
||||
@@ -681,17 +672,13 @@ func executeRedisQuery(instance *model.Instance, dbSelect string, command string
|
||||
}
|
||||
}
|
||||
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", instance.Host, instance.Port),
|
||||
Password: password,
|
||||
DB: redisDB,
|
||||
})
|
||||
client, err := getRedisClient(instance, redisDB)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
return nil, fmt.Errorf("Redis connection failed: %v", err)
|
||||
}
|
||||
|
||||
parts := strings.Fields(command)
|
||||
if len(parts) == 0 {
|
||||
|
||||
Reference in new issue
Block a user