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

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

@ -1,7 +1,6 @@
package main package main
import ( import (
"bytes"
"context" "context"
"fmt" "fmt"
"net" "net"
@ -10,8 +9,6 @@ import (
"strconv" "strconv"
"time" "time"
"gopkg.in/yaml.v3"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
@ -61,12 +58,8 @@ func run(port int) error {
return err return err
} }
fmt.Println("api init discov client success") 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") 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 return err
} }
fmt.Println("api register public config to discov success") fmt.Println("api register public config to discov success")

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

@ -48,7 +48,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*
return nil, err return nil, err
} }
resp.Token = token resp.Token = token
resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire * 24 * 60 * 60
return &resp, nil return &resp, nil
} }

@ -7,10 +7,7 @@ import (
//go:embed version //go:embed version
var Version string var Version string
var Config struct { var Config config
config
Notification notification
}
type CallBackConfig struct { type CallBackConfig struct {
Enable bool `yaml:"enable"` Enable bool `yaml:"enable"`
@ -264,6 +261,7 @@ type config struct {
MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"`
ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"`
} `yaml:"prometheus"` } `yaml:"prometheus"`
Notification notification `yaml:"notification"`
} }
type notification struct { type notification struct {

@ -1,6 +1,7 @@
package config package config
import ( import (
"bytes"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
@ -86,7 +87,7 @@ func (c *config) GetConfFromRegistry(registry discoveryregistry.SvcDiscoveryRegi
} }
func InitConfig(configFolderPath string) error { func InitConfig(configFolderPath string) error {
err := Config.initConfig(&Config.config, FileName, configFolderPath) err := Config.initConfig(&Config, FileName, configFolderPath)
if err != nil { if err != nil {
return err return err
} }
@ -96,3 +97,11 @@ func InitConfig(configFolderPath string) error {
} }
return nil 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