Merge remote-tracking branch 'origin/superGroup' into superGroup

pull/236/head
skiffer-git 2 years ago
commit cacde08e99

@ -23,7 +23,7 @@ mysql:
mongo:
dbUri: ""#当dbUri值不为空则直接使用该值
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
dbAddress: 127.0.0.1:37017 #单机时为mongo地址使用分片集群时为mongos地址 默认即可
dbDirect: false
dbTimeout: 60
dbDatabase: openIM #mongo db 默认即可
@ -34,12 +34,12 @@ mongo:
dbRetainChatRecords: 3650 #mongo保存离线消息时间根据需求修改
redis:
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机填写一个地址即可使用redis集群时候填写集群中多个节点地址主从地址都可以填写增加容灾能力,默认即可
dbMaxIdle: 128
dbMaxActive: 0
dbIdleTimeout: 120
dbPassWord: openIM #redis密码 建议修改
enableCluster: false
enableCluster: false #如果外部redis以集群方式启动需要打开此开关
kafka:
ws2mschat:
@ -55,8 +55,8 @@ kafka:
addr: [ 127.0.0.1:9092 ] #kafka配置默认即可
topic: "ms2ps_chat"
consumergroupid:
msgToRedis: redis
msgToMongo: mongo
msgToTransfer: mongo
msgToMongo: mongo_ex
msgToMySql: mysql
msgToPush: push

@ -261,7 +261,7 @@ func randomEnglishName() string {
}
func randomPosition() string {
l := []string{"Golang工程师", "前端工程师", "后端工程师", "产品经理", "测试开发工程师", "运维开发工程师"}
l := []string{"后端工程师", "前端工程师", "设计师"}
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(l) - 1)
return l[index]

@ -85,24 +85,24 @@ type config struct {
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
}
Mongo struct {
DBUri string `yaml:"dbUri"`
DBAddress []string `yaml:"dbAddress"`
DBDirect bool `yaml:"dbDirect"`
DBTimeout int `yaml:"dbTimeout"`
DBDatabase string `yaml:"dbDatabase"`
DBSource string `yaml:"dbSource"`
DBUserName string `yaml:"dbUserName"`
DBPassword string `yaml:"dbPassword"`
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
DBUri string `yaml:"dbUri"`
DBAddress string `yaml:"dbAddress"`
DBDirect bool `yaml:"dbDirect"`
DBTimeout int `yaml:"dbTimeout"`
DBDatabase string `yaml:"dbDatabase"`
DBSource string `yaml:"dbSource"`
DBUserName string `yaml:"dbUserName"`
DBPassword string `yaml:"dbPassword"`
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
}
Redis struct {
DBAddress string `yaml:"dbAddress"`
DBMaxIdle int `yaml:"dbMaxIdle"`
DBMaxActive int `yaml:"dbMaxActive"`
DBIdleTimeout int `yaml:"dbIdleTimeout"`
DBPassWord string `yaml:"dbPassWord"`
EnableCluster bool `yaml:"enableCluster"`
DBAddress []string `yaml:"dbAddress"`
DBMaxIdle int `yaml:"dbMaxIdle"`
DBMaxActive int `yaml:"dbMaxActive"`
DBIdleTimeout int `yaml:"dbIdleTimeout"`
DBPassWord string `yaml:"dbPassWord"`
EnableCluster bool `yaml:"enableCluster"`
}
RpcPort struct {
OpenImUserPort []int `yaml:"openImUserPort"`
@ -213,7 +213,7 @@ type config struct {
Topic string `yaml:"topic"`
}
ConsumerGroupID struct {
MsgToRedis string `yaml:"msgToRedis"`
MsgToRedis string `yaml:"msgToTransfer"`
MsgToMongo string `yaml:"msgToMongo"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`

@ -56,11 +56,11 @@ func init() {
uri = config.Config.Mongo.DBUri
} else {
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress,
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
} else {
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
config.Config.Mongo.DBAddress, config.Config.Mongo.DBDatabase,
config.Config.Mongo.DBMaxPoolSize)
}
}
@ -123,7 +123,7 @@ func init() {
defer cancel()
if config.Config.Redis.EnableCluster {
DB.rdb = go_redis.NewClusterClient(&go_redis.ClusterOptions{
Addrs: []string{config.Config.Redis.DBAddress},
Addrs: config.Config.Redis.DBAddress,
PoolSize: 50,
})
_, err = DB.rdb.Ping(ctx).Result()
@ -132,7 +132,7 @@ func init() {
}
} else {
DB.rdb = go_redis.NewClient(&go_redis.Options{
Addr: config.Config.Redis.DBAddress,
Addr: config.Config.Redis.DBAddress[0],
Password: config.Config.Redis.DBPassWord, // no password set
DB: 0, // use default DB
PoolSize: 100, // 连接池大小

@ -302,6 +302,6 @@ func GetRandomDepartmentID() (string, error) {
return "", err
}
department := &db.Department{}
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ?", "").First(department).Error
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ? AND department_id != ?", "", "0").First(department).Error
return department.DepartmentID, err
}

@ -17,11 +17,11 @@ func init() {
uri = config.Config.Mongo.DBUri
} else {
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress,
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
} else {
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
config.Config.Mongo.DBAddress, config.Config.Mongo.DBDatabase,
config.Config.Mongo.DBMaxPoolSize)
}
}

Loading…
Cancel
Save