Skip to content

Commit

Permalink
修改配置文件名称。
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwong1989 committed Jul 20, 2022
1 parent ca431c5 commit 9a71224
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 14 deletions.
5 changes: 4 additions & 1 deletion cmd/ismg/cmpp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ var log = logging.GetDefaultLogger()

func main() {
rand.Seed(time.Now().Unix()) // 随机种子
cmpp.Conf = yml_config.CreateYamlFactory("cmpp.yaml")

cmpp.Conf = yml_config.CreateYamlFactory("cmpp")
cmpp.Conf.ConfigFileChangeListen()

dc := cmpp.Conf.GetInt("data-center-id")
wk := cmpp.Conf.GetInt("worker-id")
cmpp.Seq32 = comm.NewCycleSequence(int32(dc), int32(wk))
Expand Down
4 changes: 3 additions & 1 deletion cmd/ismg/cmpp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (

func init() {
rand.Seed(time.Now().Unix()) // 随机种子
cmpp.Conf = yml_config.CreateYamlFactory("cmpp.yaml")
cmpp.Conf = yml_config.CreateYamlFactory("cmpp")
cmpp.Conf.ConfigFileChangeListen()

dc := cmpp.Conf.GetInt("data-center-id")
wk := cmpp.Conf.GetInt("worker-id")
cmpp.Seq32 = comm.NewCycleSequence(int32(dc), int32(wk))
Expand Down
5 changes: 4 additions & 1 deletion cmd/ismg/smgp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ var log = logging.GetDefaultLogger()

func main() {
rand.Seed(time.Now().Unix()) // 随机种子
smgp.Conf = yml_config.CreateYamlFactory("smgp.yaml")

smgp.Conf = yml_config.CreateYamlFactory("smgp")
smgp.Conf.ConfigFileChangeListen()

dc := smgp.Conf.GetInt("data-center-id")
wk := smgp.Conf.GetInt("worker-id")
smgwId := smgp.Conf.GetString("smgw-id")
Expand Down
4 changes: 3 additions & 1 deletion cmd/ismg/smgp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (

func init() {
rand.Seed(time.Now().Unix()) // 随机种子
smgp.Conf = yml_config.CreateYamlFactory("smgp.yaml")
smgp.Conf = yml_config.CreateYamlFactory("smgp")
smgp.Conf.ConfigFileChangeListen()

dc := smgp.Conf.GetInt("data-center-id")
wk := smgp.Conf.GetInt("worker-id")
smgwId := smgp.Conf.GetString("smgw-id")
Expand Down
4 changes: 3 additions & 1 deletion codec/cmpp/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (

func init() {
rand.Seed(time.Now().Unix()) // 随机种子
Conf = yml_config.CreateYamlFactory("cmpp.yaml")
Conf = yml_config.CreateYamlFactory("cmpp")
Conf.ConfigFileChangeListen()

dc := Conf.GetInt("data-center-id")
wk := Conf.GetInt("worker-id")
Seq32 = comm.NewCycleSequence(int32(dc), int32(wk))
Expand Down
4 changes: 3 additions & 1 deletion codec/smgp/active_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
)

func init() {
Conf = yml_config.CreateYamlFactory("smgp.yaml")
Conf = yml_config.CreateYamlFactory("smgp")
Conf.ConfigFileChangeListen()

dc := Conf.GetInt("data-center-id")
wk := Conf.GetInt("worker-id")
smgwId := Conf.GetString("smgw-id")
Expand Down
2 changes: 1 addition & 1 deletion comm/tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ func TestUcs2Encode(t *testing.T) {
}

func TestDiceCheck(t *testing.T) {
assert.True(t, DiceCheck(0.99))
assert.False(t, DiceCheck(1))
}
7 changes: 2 additions & 5 deletions comm/yml_config/yml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,16 @@ func CreateYamlFactory(fileName ...string) YmlConfig {
yamlConfig.SetConfigName(fileName[0])
}
// 设置配置文件类型(后缀)为 yml
yamlConfig.SetConfigType("yaml")
yamlConfig.SetConfigType("yml")

if err := yamlConfig.ReadInConfig(); err != nil {
log.Fatalf("配置文件初始化失败:", err.Error())
}

conf := &ymlLoader{
return &ymlLoader{
viper: yamlConfig,
mu: new(sync.Mutex),
}
conf.ConfigFileChangeListen()

return conf
}

type ymlLoader struct {
Expand Down
2 changes: 1 addition & 1 deletion config/cmpp.yaml → config/cmpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ default-valid-duration: 2h

### 以下是模拟网关运行情况的参数 ###
# 成功率:
success-rate: 0.95
success-rate: 0.96
# Mt响应的最大与最小时间,状态报告在fix-report-resp-ms后发送
min-submit-resp-ms: 1
max-submit-resp-ms: 3
Expand Down
2 changes: 1 addition & 1 deletion config/smgp.yaml → config/smgp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ default-valid-duration: 2h
# 95 表示 95%
# 99 表示 99%
# 999 表示 99.9%
success-rate: 965
success-rate: 96
# Mt响应的最大与最小时间,状态报告在fix-report-resp-ms后发送
min-submit-resp-ms: 1
max-submit-resp-ms: 3
Expand Down

0 comments on commit 9a71224

Please sign in to comment.