mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 13:12:12 +08:00
chore: config
This commit is contained in:
parent
6d60997105
commit
7f1a723557
5
go.mod
5
go.mod
@ -221,3 +221,8 @@ require (
|
||||
golang.org/x/crypto v0.27.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
|
||||
replace (
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.66 => C:\App\Project\protocol
|
||||
github.com/openimsdk/tools v0.0.50-alpha.57 => C:\App\Project\tools
|
||||
)
|
||||
@ -9,17 +9,17 @@ import (
|
||||
)
|
||||
|
||||
type ConfigManager struct {
|
||||
apiConfig *config.API
|
||||
config *config.AllConfig
|
||||
}
|
||||
|
||||
func NewConfigManager(api *config.API) *ConfigManager {
|
||||
func NewConfigManager(cfg *config.AllConfig) *ConfigManager {
|
||||
return &ConfigManager{
|
||||
apiConfig: api,
|
||||
config: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (cm *ConfigManager) LoadApiConfig(c *gin.Context) {
|
||||
b, err := json.Marshal(cm.apiConfig)
|
||||
func (cm *ConfigManager) GetConfig(c *gin.Context) {
|
||||
b, err := json.Marshal(cm.config)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, err) // args option error
|
||||
return
|
||||
|
||||
@ -44,9 +44,7 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
API conf.API
|
||||
Share conf.Share
|
||||
Discovery conf.Discovery
|
||||
*conf.AllConfig
|
||||
|
||||
RuntimeEnv string
|
||||
}
|
||||
|
||||
@ -259,9 +259,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
||||
proDiscoveryGroup.GET("/msg_gateway", pd.MessageGateway)
|
||||
proDiscoveryGroup.GET("/msg_transfer", pd.MessageTransfer)
|
||||
|
||||
cm := NewConfigManager(&config.API)
|
||||
cm := NewConfigManager(config.AllConfig)
|
||||
configGroup := r.Group("/config")
|
||||
configGroup.GET("/api", cm.LoadApiConfig)
|
||||
configGroup.GET("/api", cm.GetConfig)
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
14
pkg/apistruct/config_manager.go
Normal file
14
pkg/apistruct/config_manager.go
Normal file
@ -0,0 +1,14 @@
|
||||
package apistruct
|
||||
|
||||
type GetConfigReq struct {
|
||||
ConfigName string `json:"config_name"`
|
||||
}
|
||||
|
||||
type GetConfigListReq struct {
|
||||
}
|
||||
|
||||
type GetConfigListResp struct {
|
||||
Environment string `json:"environment"`
|
||||
Version string `json:"version"`
|
||||
ConfigNames []string `json:"config_names"`
|
||||
}
|
||||
@ -679,3 +679,49 @@ func InitNotification(notification *Notification) {
|
||||
notification.ConversationSetPrivate.UnreadCount = false
|
||||
notification.ConversationSetPrivate.ReliabilityLevel = 1
|
||||
}
|
||||
|
||||
type AllConfig struct {
|
||||
Discovery Discovery
|
||||
LocalCache LocalCache
|
||||
Log Log
|
||||
Notification Notification
|
||||
API API
|
||||
CronTask CronTask
|
||||
MsgGateway MsgGateway
|
||||
MsgTransfer MsgTransfer
|
||||
Push Push
|
||||
Auth Auth
|
||||
Conversation Conversation
|
||||
Friend Friend
|
||||
Group Group
|
||||
Msg Msg
|
||||
Third Third
|
||||
User User
|
||||
Share Share
|
||||
Webhooks Webhooks
|
||||
}
|
||||
|
||||
var (
|
||||
NotificationFileName = "notification.yml"
|
||||
ShareFileName = "share.yml"
|
||||
WebhooksConfigFileName = "webhooks.yml"
|
||||
LocalCacheConfigFileName = "local-cache.yml"
|
||||
KafkaConfigFileName = "kafka.yml"
|
||||
RedisConfigFileName = "redis.yml"
|
||||
MongodbConfigFileName = "mongodb.yml"
|
||||
MinioConfigFileName = "minio.yml"
|
||||
LogConfigFileName = "log.yml"
|
||||
OpenIMAPICfgFileName = "openim-api.yml"
|
||||
OpenIMCronTaskCfgFileName = "openim-crontask.yml"
|
||||
OpenIMMsgGatewayCfgFileName = "openim-msggateway.yml"
|
||||
OpenIMMsgTransferCfgFileName = "openim-msgtransfer.yml"
|
||||
OpenIMPushCfgFileName = "openim-push.yml"
|
||||
OpenIMRPCAuthCfgFileName = "openim-rpc-auth.yml"
|
||||
OpenIMRPCConversationCfgFileName = "openim-rpc-conversation.yml"
|
||||
OpenIMRPCFriendCfgFileName = "openim-rpc-friend.yml"
|
||||
OpenIMRPCGroupCfgFileName = "openim-rpc-group.yml"
|
||||
OpenIMRPCMsgCfgFileName = "openim-rpc-msg.yml"
|
||||
OpenIMRPCThirdCfgFileName = "openim-rpc-third.yml"
|
||||
OpenIMRPCUserCfgFileName = "openim-rpc-user.yml"
|
||||
DiscoveryConfigFilename = "discovery.yml"
|
||||
)
|
||||
|
||||
@ -26,9 +26,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
FileName = "config.yaml"
|
||||
NotificationFileName = "notification.yaml"
|
||||
DefaultFolderPath = "../config/"
|
||||
DefaultFolderPath = "../config/"
|
||||
)
|
||||
|
||||
// return absolude path join ../config/, this is k8s container config path.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user