optimization: change the configuration file from being read globally … (#1935)

* optimization: change the configuration file from being read globally to being read independently.

* optimization: change the configuration file from being read globally to being read independently.

* optimization: change the configuration file from being read globally to being read independently.

* optimization: config file changed to dependency injection.

* fix: replace global config with dependency injection

* fix: replace global config with dependency injection

* fix: import the enough param

* fix: import the enough param

* fix: import the enough param

* fix: fix the component check of path

* fix: fix the kafka of tls is nil problem

* fix: fix the TLS.CACrt is nil error

* fix: fix the valiable shadows problem

* fix: fix the comflect

* optimization: message remove options.

* fix: fix the param pass error

* fix: find error

* fix: find error

* fix: find eror

* fix: find error

* fix: find error

* fix: del the undifined func

* fix: find error

* fix: fix the error

* fix: pass config

* fix: find error

* fix: find error

* fix: find error

* fix: find error

* fix: find error

* fix: fix the config

* fix: fix the error

* fix: fix the config pass error

* fix: fix the eror

* fix: fix the error

* fix: fix the error

* fix: fix the error

* fix: find error

* fix: fix the error

* fix: fix the config

* fix: add return err

* fix: fix the err2

* fix: err

* fix: fix the func

* fix: del the chinese comment

* fix: fix the func

* fix: fix the gateway_test logic

* fix: s3

* test

* test

* fix: not found

---------

Co-authored-by: luhaoling <2198702716@qq.com>
Co-authored-by: withchao <993506633@qq.com>
This commit is contained in:
OpenIM-Gordon
2024-03-05 17:53:22 +08:00
committed by GitHub
parent efb8310531
commit 383758782e
114 changed files with 1743 additions and 1802 deletions
+27 -25
View File
@@ -33,27 +33,28 @@ import (
)
func Test_BatchInsertChat2DB(t *testing.T) {
config.Config.Mongo.Address = []string{"192.168.44.128:37017"}
// config.Config.Mongo.Timeout = 60
config.Config.Mongo.Database = "openIM"
// config.Config.Mongo.Source = "admin"
config.Config.Mongo.Username = "root"
config.Config.Mongo.Password = "openIM123"
config.Config.Mongo.MaxPoolSize = 100
config.Config.RetainChatRecords = 3650
config.Config.ChatRecordsClearTime = "0 2 * * 3"
conf := config.NewGlobalConfig()
conf.Mongo.Address = []string{"192.168.44.128:37017"}
// conf.Mongo.Timeout = 60
conf.Mongo.Database = "openIM"
// conf.Mongo.Source = "admin"
conf.Mongo.Username = "root"
conf.Mongo.Password = "openIM123"
conf.Mongo.MaxPoolSize = 100
conf.RetainChatRecords = 3650
conf.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo()
mongo, err := unrelation.NewMongo(conf)
if err != nil {
t.Fatal(err)
}
err = mongo.GetDatabase().Client().Ping(context.Background(), nil)
err = mongo.GetDatabase(conf.Mongo.Database).Client().Ping(context.Background(), nil)
if err != nil {
panic(err)
}
db := &commonMsgDatabase{
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase(conf.Mongo.Database)),
}
//ctx := context.Background()
@@ -70,7 +71,7 @@ func Test_BatchInsertChat2DB(t *testing.T) {
//}
_ = db.BatchInsertChat2DB
c := mongo.GetDatabase().Collection("msg")
c := mongo.GetDatabase(conf.Mongo.Database).Collection("msg")
ch := make(chan int)
rand.Seed(time.Now().UnixNano())
@@ -144,26 +145,27 @@ func Test_BatchInsertChat2DB(t *testing.T) {
}
func GetDB() *commonMsgDatabase {
config.Config.Mongo.Address = []string{"203.56.175.233:37017"}
// config.Config.Mongo.Timeout = 60
config.Config.Mongo.Database = "openim_v3"
// config.Config.Mongo.Source = "admin"
config.Config.Mongo.Username = "root"
config.Config.Mongo.Password = "openIM123"
config.Config.Mongo.MaxPoolSize = 100
config.Config.RetainChatRecords = 3650
config.Config.ChatRecordsClearTime = "0 2 * * 3"
conf := config.NewGlobalConfig()
conf.Mongo.Address = []string{"203.56.175.233:37017"}
// conf.Mongo.Timeout = 60
conf.Mongo.Database = "openim_v3"
// conf.Mongo.Source = "admin"
conf.Mongo.Username = "root"
conf.Mongo.Password = "openIM123"
conf.Mongo.MaxPoolSize = 100
conf.RetainChatRecords = 3650
conf.ChatRecordsClearTime = "0 2 * * 3"
mongo, err := unrelation.NewMongo()
mongo, err := unrelation.NewMongo(conf)
if err != nil {
panic(err)
}
err = mongo.GetDatabase().Client().Ping(context.Background(), nil)
err = mongo.GetDatabase(conf.Mongo.Database).Client().Ping(context.Background(), nil)
if err != nil {
panic(err)
}
return &commonMsgDatabase{
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase(conf.Mongo.Database)),
}
}