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

pull/454/head
skiffer-git 2 years ago
commit d7e43d3ba5

@ -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")

@ -107,8 +107,7 @@ rpcPort: #rpc服务端口不建议修改
openImAuthPort: [ 10160 ]
openImPushPort: [ 10170 ]
openImConversationPort: [ 10180 ]
openImRtcPort: [ 10190 ]
openImThirdPort: [ 10200 ]
openImThirdPort: [ 10190 ]
rpcRegisterName: #rpc注册服务名不建议修改
openImUserName: User

@ -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
}

@ -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"`
@ -264,6 +261,7 @@ type config struct {
MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"`
ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"`
} `yaml:"prometheus"`
Notification notification `yaml:"notification"`
}
type notification struct {

@ -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"
@ -86,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
}
@ -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()
}

Loading…
Cancel
Save