mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
Adjust configuration settings
This commit is contained in:
parent
54630464bd
commit
5a5f2c48e7
@ -2,3 +2,6 @@ redis:
|
|||||||
address: [ 172.28.0.1:16379 ]
|
address: [ 172.28.0.1:16379 ]
|
||||||
username: ''
|
username: ''
|
||||||
password: openIM123
|
password: openIM123
|
||||||
|
clusterMode: false
|
||||||
|
db: 0
|
||||||
|
MaxRetry: 10
|
||||||
@ -15,11 +15,8 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"github.com/openimsdk/tools/db/mongoutil"
|
"github.com/openimsdk/tools/db/mongoutil"
|
||||||
"github.com/openimsdk/tools/db/redisutil"
|
"github.com/openimsdk/tools/db/redisutil"
|
||||||
"github.com/openimsdk/tools/discovery"
|
|
||||||
"github.com/openimsdk/tools/system/program"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -631,76 +628,31 @@ type Redis struct {
|
|||||||
Address []string `mapstructure:"address"`
|
Address []string `mapstructure:"address"`
|
||||||
Username string `mapstructure:"username"`
|
Username string `mapstructure:"username"`
|
||||||
Password string `mapstructure:"password"`
|
Password string `mapstructure:"password"`
|
||||||
|
ClusterMode bool `mapstructure:"clusterMode"`
|
||||||
|
DB int `mapstructure:"db"`
|
||||||
|
MaxRetry int `mapstructure:"MaxRetry"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Hook struct {
|
||||||
|
Enable bool `mapstructure:"enable"`
|
||||||
|
Timeout int `mapstructure:"timeout"`
|
||||||
|
FailedContinue bool `mapstructure:"failedContinue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Webhooks struct {
|
type Webhooks struct {
|
||||||
URL string `mapstructure:"url"`
|
URL string `mapstructure:"url"`
|
||||||
BeforeSendSingleMsg struct {
|
BeforeSendSingleMsg Hook `mapstructure:"beforeSendSingleMsg"`
|
||||||
Enable bool `mapstructure:"enable"`
|
BeforeUpdateUserInfoEx Hook `mapstructure:"beforeUpdateUserInfoEx"`
|
||||||
Timeout int `mapstructure:"timeout"`
|
AfterUpdateUserInfoEx Hook `mapstructure:"afterUpdateUserInfoEx"`
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
AfterSendSingleMsg Hook `mapstructure:"afterSendSingleMsg"`
|
||||||
} `mapstructure:"beforeSendSingleMsg"`
|
BeforeSendGroupMsg Hook `mapstructure:"beforeSendGroupMsg"`
|
||||||
BeforeUpdateUserInfoEx struct {
|
AfterSendGroupMsg Hook `mapstructure:"afterSendGroupMsg"`
|
||||||
Enable bool `mapstructure:"enable"`
|
MsgModify Hook `mapstructure:"msgModify"`
|
||||||
Timeout int `mapstructure:"timeout"`
|
UserOnline Hook `mapstructure:"userOnline"`
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
UserOffline Hook `mapstructure:"userOffline"`
|
||||||
} `mapstructure:"beforeUpdateUserInfoEx"`
|
UserKickOff Hook `mapstructure:"userKickOff"`
|
||||||
AfterUpdateUserInfoEx struct {
|
OfflinePush Hook `mapstructure:"offlinePush"`
|
||||||
Enable bool `mapstructure:"enable"`
|
OnlinePush Hook `mapstructure:"onlinePush"`
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"afterUpdateUserInfoEx"`
|
|
||||||
AfterSendSingleMsg struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"afterSendSingleMsg"`
|
|
||||||
BeforeSendGroupMsg struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"beforeSendGroupMsg"`
|
|
||||||
AfterSendGroupMsg struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"afterSendGroupMsg"`
|
|
||||||
MsgModify struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"msgModify"`
|
|
||||||
UserOnline struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"userOnline"`
|
|
||||||
UserOffline struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"userOffline"`
|
|
||||||
UserKickOff struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"userKickOff"`
|
|
||||||
OfflinePush struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"offlinePush"`
|
|
||||||
OnlinePush struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"onlinePush"`
|
|
||||||
SuperGroupOnlinePush struct {
|
|
||||||
Enable bool `mapstructure:"enable"`
|
|
||||||
Timeout int `mapstructure:"timeout"`
|
|
||||||
FailedContinue bool `mapstructure:"failedContinue"`
|
|
||||||
} `mapstructure:"superGroupOnlinePush"`
|
|
||||||
// Add additional fields here following the same pattern for other hooks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZooKeeper struct {
|
type ZooKeeper struct {
|
||||||
@ -744,55 +696,14 @@ func (r *Redis) Build() *redisutil.Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l LocalCache) Failed() time.Duration {
|
func (l *CacheConfig) Failed() time.Duration {
|
||||||
return time.Second * time.Duration(l.FailedExpire)
|
return time.Second * time.Duration(l.FailedExpire)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l LocalCache) Success() time.Duration {
|
func (l *CacheConfig) Success() time.Duration {
|
||||||
return time.Second * time.Duration(l.SuccessExpire)
|
return time.Second * time.Duration(l.SuccessExpire)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l LocalCache) Enable() bool {
|
func (l *CacheConfig) Enable() bool {
|
||||||
return l.Topic != "" && l.SlotNum > 0 && l.SlotSize > 0
|
return l.Topic != "" && l.SlotNum > 0 && l.SlotSize > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type localCache struct {
|
|
||||||
User LocalCache `yaml:"user"`
|
|
||||||
Group LocalCache `yaml:"group"`
|
|
||||||
Friend LocalCache `yaml:"friend"`
|
|
||||||
Conversation LocalCache `yaml:"conversation"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) GetServiceNames() []string {
|
|
||||||
return []string{
|
|
||||||
c.RpcRegisterName.OpenImUserName,
|
|
||||||
c.RpcRegisterName.OpenImFriendName,
|
|
||||||
c.RpcRegisterName.OpenImMsgName,
|
|
||||||
c.RpcRegisterName.OpenImPushName,
|
|
||||||
c.RpcRegisterName.OpenImMessageGatewayName,
|
|
||||||
c.RpcRegisterName.OpenImGroupName,
|
|
||||||
c.RpcRegisterName.OpenImAuthName,
|
|
||||||
c.RpcRegisterName.OpenImConversationName,
|
|
||||||
c.RpcRegisterName.OpenImThirdName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) RegisterConf2Registry(registry discovery.SvcDiscoveryRegistry) error {
|
|
||||||
data, err := yaml.Marshal(c)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return registry.RegisterConf2Registry(ConfKey, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) GetConfFromRegistry(registry discovery.SvcDiscoveryRegistry) ([]byte, error) {
|
|
||||||
return registry.GetConfFromRegistry(ConfKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *GlobalConfig) EncodeConfig() []byte {
|
|
||||||
buf := bytes.NewBuffer(nil)
|
|
||||||
if err := yaml.NewEncoder(buf).Encode(c); err != nil {
|
|
||||||
program.ExitWithError(err)
|
|
||||||
}
|
|
||||||
return buf.Bytes()
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user