mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 21:22:16 +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
|
golang.org/x/crypto v0.27.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.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 {
|
type ConfigManager struct {
|
||||||
apiConfig *config.API
|
config *config.AllConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigManager(api *config.API) *ConfigManager {
|
func NewConfigManager(cfg *config.AllConfig) *ConfigManager {
|
||||||
return &ConfigManager{
|
return &ConfigManager{
|
||||||
apiConfig: api,
|
config: cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *ConfigManager) LoadApiConfig(c *gin.Context) {
|
func (cm *ConfigManager) GetConfig(c *gin.Context) {
|
||||||
b, err := json.Marshal(cm.apiConfig)
|
b, err := json.Marshal(cm.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err) // args option error
|
apiresp.GinError(c, err) // args option error
|
||||||
return
|
return
|
||||||
|
|||||||
@ -44,9 +44,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
API conf.API
|
*conf.AllConfig
|
||||||
Share conf.Share
|
|
||||||
Discovery conf.Discovery
|
|
||||||
|
|
||||||
RuntimeEnv string
|
RuntimeEnv string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -259,9 +259,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
proDiscoveryGroup.GET("/msg_gateway", pd.MessageGateway)
|
proDiscoveryGroup.GET("/msg_gateway", pd.MessageGateway)
|
||||||
proDiscoveryGroup.GET("/msg_transfer", pd.MessageTransfer)
|
proDiscoveryGroup.GET("/msg_transfer", pd.MessageTransfer)
|
||||||
|
|
||||||
cm := NewConfigManager(&config.API)
|
cm := NewConfigManager(config.AllConfig)
|
||||||
configGroup := r.Group("/config")
|
configGroup := r.Group("/config")
|
||||||
configGroup.GET("/api", cm.LoadApiConfig)
|
configGroup.GET("/api", cm.GetConfig)
|
||||||
return r
|
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.UnreadCount = false
|
||||||
notification.ConversationSetPrivate.ReliabilityLevel = 1
|
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 (
|
const (
|
||||||
FileName = "config.yaml"
|
DefaultFolderPath = "../config/"
|
||||||
NotificationFileName = "notification.yaml"
|
|
||||||
DefaultFolderPath = "../config/"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// return absolude path join ../config/, this is k8s container config path.
|
// return absolude path join ../config/, this is k8s container config path.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user