Skip to content

Commit a3c43a4

Browse files
authored
fix: seq conversion not reading env in docker environment (#3130)
* pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * fix: DeleteDoc crash * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: user msg timestamp * seq read config * seq read config
1 parent 489571f commit a3c43a4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/seq/internal/seq.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ import (
1515
"syscall"
1616
"time"
1717

18+
"github.com/mitchellh/mapstructure"
1819
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
1920
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
2021
"github.com/openimsdk/tools/db/mongoutil"
2122
"github.com/openimsdk/tools/db/redisutil"
2223
"github.com/openimsdk/tools/utils/runtimeenv"
2324
"github.com/redis/go-redis/v9"
25+
"github.com/spf13/viper"
2426
"go.mongodb.org/mongo-driver/bson"
2527
"go.mongodb.org/mongo-driver/mongo"
2628
"go.mongodb.org/mongo-driver/mongo/options"
27-
"gopkg.in/yaml.v3"
2829
)
2930

3031
const (
@@ -45,13 +46,19 @@ func readConfig[T any](dir string, name string) (*T, error) {
4546
if runtimeenv.PrintRuntimeEnvironment() == config.KUBERNETES {
4647
dir = os.Getenv(config.MountConfigFilePath)
4748
}
48-
49-
data, err := os.ReadFile(filepath.Join(dir, name))
50-
if err != nil {
49+
v := viper.New()
50+
v.SetEnvPrefix(config.EnvPrefixMap[name])
51+
v.AutomaticEnv()
52+
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
53+
v.SetConfigFile(filepath.Join(dir, name))
54+
if err := v.ReadInConfig(); err != nil {
5155
return nil, err
5256
}
57+
fn := func(config *mapstructure.DecoderConfig) {
58+
config.TagName = "mapstructure"
59+
}
5360
var conf T
54-
if err := yaml.Unmarshal(data, &conf); err != nil {
61+
if err := v.Unmarshal(&conf, fn); err != nil {
5562
return nil, err
5663
}
5764
return &conf, nil

0 commit comments

Comments
 (0)