feat: support redis sentinel. (#3423)

* feat: support redis sentinel.

* update docker compose contents.

* update config contents.

* revert content.

* supoort redisMode.

* update config.

* remvove print.
This commit is contained in:
Monet Lee
2025-06-18 14:31:09 +08:00
committed by GitHub
parent 1baf9a8e0f
commit 8f7b02979d
7 changed files with 52 additions and 27 deletions
+8 -4
View File
@@ -28,6 +28,8 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)
const StructTagName = "yaml"
const (
MaxSeq = "MAX_SEQ:"
MinSeq = "MIN_SEQ:"
@@ -54,13 +56,14 @@ func readConfig[T any](dir string, name string) (*T, error) {
if err := v.ReadInConfig(); err != nil {
return nil, err
}
fn := func(config *mapstructure.DecoderConfig) {
config.TagName = "mapstructure"
}
var conf T
if err := v.Unmarshal(&conf, fn); err != nil {
if err := v.Unmarshal(&conf, func(config *mapstructure.DecoderConfig) {
config.TagName = StructTagName
}); err != nil {
return nil, err
}
return &conf, nil
}
@@ -69,6 +72,7 @@ func Main(conf string, del time.Duration) error {
if err != nil {
return err
}
mongodbConfig, err := readConfig[config.Mongo](conf, config.MongodbConfigFileName)
if err != nil {
return err