fix(bridge-history-api): change redis config (#1062)

Co-authored-by: colinlyguo <colinlyguo@users.noreply.github.com>
This commit is contained in:
colin
2023-12-29 23:40:44 +08:00
committed by GitHub
parent 693974ded4
commit fdb71dd6aa
4 changed files with 14 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package app
import (
"crypto/tls"
"fmt"
"os"
"os/signal"
@@ -52,11 +53,16 @@ func action(ctx *cli.Context) error {
log.Error("failed to close db", "err", err)
}
}()
redisClient := redis.NewClient(&redis.Options{
opts := &redis.Options{
Addr: cfg.Redis.Address,
Username: cfg.Redis.Username,
Password: cfg.Redis.Password,
DB: cfg.Redis.DB,
})
}
// Production Redis service has enabled transit_encryption.
if !cfg.Redis.Local {
opts.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12}
}
redisClient := redis.NewClient(opts)
api.InitController(db, redisClient)
router := gin.Default()

View File

@@ -45,7 +45,8 @@
},
"redis": {
"address": "localhost:6379",
"username": "default",
"password": "",
"db": 0
"local": true
}
}

View File

@@ -33,8 +33,10 @@ type LayerConfig struct {
// RedisConfig redis config
type RedisConfig struct {
Address string `json:"address"`
Username string `json:"username"`
Password string `json:"password"`
DB int `json:"db"`
Local bool `json:"local"`
}
// Config is the configuration of the bridge history backend

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "v4.3.45"
var tag = "v4.3.46"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {