From d823d11cdd65ea183ae3458b951e6160541012a3 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 29 Jun 2023 15:35:29 +0800 Subject: [PATCH 1/5] new config --- config/config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 7ee8265d0..5da39fa12 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -116,8 +116,7 @@ rpcPort: #rpc服务端口 默认即可 openImAuthPort: [ 10160 ] openImPushPort: [ 10170 ] openImConversationPort: [ 10180 ] - openImRtcPort: [ 10190 ] - openImThirdPort: [ 10200 ] + openImThirdPort: [ 10190 ] rpcRegisterName: #rpc注册服务名,默认即可 openImUserName: User From 1e65eb68c2d1b4c3a11b442e02c0f322106f2ab6 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 29 Jun 2023 15:40:28 +0800 Subject: [PATCH 2/5] new config --- cmd/api/main.go | 9 +-------- pkg/common/config/parse.go | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 079747003..277e0d47b 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "context" "fmt" "net" @@ -10,8 +9,6 @@ import ( "strconv" "time" - "gopkg.in/yaml.v3" - "net/http" _ "net/http/pprof" @@ -61,12 +58,8 @@ func run(port int) error { return err } fmt.Println("api init discov client success") - buf := bytes.NewBuffer(nil) - if err := yaml.NewEncoder(buf).Encode(config.Config); err != nil { - return err - } fmt.Println("api register public config to discov") - if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, buf.Bytes()); err != nil { + if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil { return err } fmt.Println("api register public config to discov success") diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 651fcc902..4c43096f7 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -1,6 +1,7 @@ package config import ( + "bytes" "fmt" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" @@ -96,3 +97,11 @@ func InitConfig(configFolderPath string) error { } return nil } + +func EncodeConfig() []byte { + buf := bytes.NewBuffer(nil) + if err := yaml.NewEncoder(buf).Encode(Config); err != nil { + panic(err) + } + return buf.Bytes() +} From d5c747fc1ad9b5fd7c18862d87f333602805e3de Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 29 Jun 2023 15:55:34 +0800 Subject: [PATCH 3/5] new config --- cmd/api/main.go | 2 +- pkg/common/config/config.go | 6 ++---- pkg/common/config/parse.go | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 277e0d47b..4d18c1529 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -59,7 +59,7 @@ func run(port int) error { } fmt.Println("api init discov client success") fmt.Println("api register public config to discov") - if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil { + if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { return err } fmt.Println("api register public config to discov success") diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 6abba786d..fe5ba230b 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -7,10 +7,7 @@ import ( //go:embed version var Version string -var Config struct { - config - Notification notification -} +var Config config type CallBackConfig struct { Enable bool `yaml:"enable"` @@ -268,6 +265,7 @@ type config struct { MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` } `yaml:"prometheus"` + Notification notification `yaml:"notification"` } type notification struct { diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 4c43096f7..d99306cb4 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -87,7 +87,7 @@ func (c *config) GetConfFromRegistry(registry discoveryregistry.SvcDiscoveryRegi } func InitConfig(configFolderPath string) error { - err := Config.initConfig(&Config.config, FileName, configFolderPath) + err := Config.initConfig(&Config, FileName, configFolderPath) if err != nil { return err } @@ -98,9 +98,9 @@ func InitConfig(configFolderPath string) error { return nil } -func EncodeConfig() []byte { +func (c *config) EncodeConfig() []byte { buf := bytes.NewBuffer(nil) - if err := yaml.NewEncoder(buf).Encode(Config); err != nil { + if err := yaml.NewEncoder(buf).Encode(c); err != nil { panic(err) } return buf.Bytes() From 4b5fcac87a9a42bfe84174875000d109b211e37a Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 29 Jun 2023 16:04:37 +0800 Subject: [PATCH 4/5] new config --- cmd/api/main.go | 2 +- pkg/common/config/parse.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 4d18c1529..277e0d47b 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -59,7 +59,7 @@ func run(port int) error { } fmt.Println("api init discov client success") fmt.Println("api register public config to discov") - if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.Config.EncodeConfig()); err != nil { + if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil { return err } fmt.Println("api register public config to discov success") diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index d99306cb4..8ab68b68f 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -98,9 +98,9 @@ func InitConfig(configFolderPath string) error { return nil } -func (c *config) EncodeConfig() []byte { +func EncodeConfig() []byte { buf := bytes.NewBuffer(nil) - if err := yaml.NewEncoder(buf).Encode(c); err != nil { + if err := yaml.NewEncoder(buf).Encode(Config); err != nil { panic(err) } return buf.Bytes() From b67decb6b1a9750215987636ce7b5ccf41b08ec8 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 29 Jun 2023 16:30:45 +0800 Subject: [PATCH 5/5] new config --- internal/rpc/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index d0a6176f4..b70daec18 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -48,7 +48,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (* return nil, err } resp.Token = token - resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire + resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire * 24 * 60 * 60 return &resp, nil }