Go: add context to redis client (#17689)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-08-02 22:50:54 +08:00
committed by GitHub
parent b2521ebf51
commit 266837eb33
31 changed files with 302 additions and 308 deletions

View File

@@ -17,7 +17,6 @@
package admin
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -113,7 +112,7 @@ func (h *Handler) Login(c *gin.Context) {
return
}
secretKey, err := server.GetSecretKey(redis.Get())
secretKey, err := server.GetSecretKey(ctx, redis.Get())
if err != nil {
common.ErrorWithCode(c, common.CodeServerError, fmt.Sprintf("Failed to get secret key: %s", err.Error()))
return
@@ -1235,8 +1234,9 @@ func (h *Handler) PingStore(c *gin.Context) {
}
func (h *Handler) PingCache(c *gin.Context) {
ctx := c.Request.Context()
redisClient := redis.Get()
if redisClient.Health() {
if redisClient.Health(ctx) {
common.SuccessNoMessage(c, "SUCCESS")
} else {
common.ErrorWithCode(c, common.CodeServerError, "cache health check failed")
@@ -1245,7 +1245,7 @@ func (h *Handler) PingCache(c *gin.Context) {
func (h *Handler) PingEngine(c *gin.Context) {
docEngine := engine.Get()
ctx := context.Background()
ctx := c.Request.Context()
if err := docEngine.Ping(ctx); err != nil {
var coded interface {
Code() common.ErrorCode

View File

@@ -1121,7 +1121,7 @@ func (s *Service) getRedisInfo(ctx context.Context) ServiceStatus {
startTime := time.Now()
redisClient := redis.Get()
if redisClient.Health() {
if redisClient.Health(ctx) {
return newServiceStatus(serviceType, name, "alive", startTime, "")
}