Skip to content

Commit 7926a87

Browse files
committed
规范命名
1 parent bd52b85 commit 7926a87

13 files changed

+63
-63
lines changed

actor/ActorComponent.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Actor
33
import (
44
"errors"
55
"github.com/zllangct/RockGO/component"
6-
"github.com/zllangct/RockGO/configComponent"
6+
"github.com/zllangct/RockGO/config"
77
"github.com/zllangct/RockGO/logger"
88
"github.com/zllangct/RockGO/timer"
99
"reflect"
@@ -44,7 +44,7 @@ func (this *ActorComponent) GetRequire() map[*Component.Object][]reflect.Type {
4444
requires := make(map[*Component.Object][]reflect.Type)
4545
//添加该组件需要根节点拥有ActorProxyComponent,ConfigComponent组件
4646
requires[this.Runtime().Root()] = []reflect.Type{
47-
reflect.TypeOf(&Config.ConfigComponent{}),
47+
reflect.TypeOf(&config.ConfigComponent{}),
4848
reflect.TypeOf(&ActorProxyComponent{}),
4949
}
5050
return requires
@@ -116,7 +116,7 @@ func (this *ActorComponent) Tell(sender IActor, message *ActorMessage, reply ...
116116

117117
if messageInfo.IsNeedReply() {
118118
select {
119-
case <-timer.After(time.Duration(Config.Config.ClusterConfig.RpcCallTimeout) * time.Millisecond):
119+
case <-timer.After(time.Duration(config.Config.ClusterConfig.RpcCallTimeout) * time.Millisecond):
120120
messageInfo.err = ErrTimeout
121121
case <-messageInfo.done:
122122
}

actor/ActorProxyComponent.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"github.com/zllangct/RockGO/cluster"
77
"github.com/zllangct/RockGO/component"
8-
"github.com/zllangct/RockGO/configComponent"
8+
"github.com/zllangct/RockGO/config"
99
"github.com/zllangct/RockGO/logger"
1010
"github.com/zllangct/RockGO/rpc"
1111
"github.com/zllangct/RockGO/utils/UUID"
@@ -32,7 +32,7 @@ func (this *ActorProxyComponent) GetRequire() map[*Component.Object][]reflect.Ty
3232
requires := make(map[*Component.Object][]reflect.Type)
3333
//添加该组件需要根节点拥有ActorProxyComponent,ConfigComponent组件
3434
requires[this.Runtime().Root()] = []reflect.Type{
35-
reflect.TypeOf(&Config.ConfigComponent{}),
35+
reflect.TypeOf(&config.ConfigComponent{}),
3636
}
3737
return requires
3838
}
@@ -43,7 +43,7 @@ func (this *ActorProxyComponent) IsUnique() int {
4343

4444
func (this *ActorProxyComponent) Initialize() error {
4545
logger.Info("ActorProxyComponent init .....")
46-
this.nodeID = Config.Config.ClusterConfig.LocalAddress
46+
this.nodeID = config.Config.ClusterConfig.LocalAddress
4747
//this.isActorMode = Config.Config.ClusterConfig.IsActorModel
4848
err := this.Runtime().Root().Find(&this.nodeComponent)
4949
if err != nil {

cluster/ChildComponent.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Cluster
33
import (
44
"fmt"
55
"github.com/zllangct/RockGO/component"
6-
"github.com/zllangct/RockGO/configComponent"
6+
"github.com/zllangct/RockGO/config"
77
"github.com/zllangct/RockGO/logger"
88
"github.com/zllangct/RockGO/rpc"
99
"github.com/zllangct/RockGO/utils"
@@ -26,7 +26,7 @@ type ChildComponent struct {
2626
func (this *ChildComponent) GetRequire() map[*Component.Object][]reflect.Type {
2727
requires := make(map[*Component.Object][]reflect.Type)
2828
requires[this.Parent().Root()] = []reflect.Type{
29-
reflect.TypeOf(&Config.ConfigComponent{}),
29+
reflect.TypeOf(&config.ConfigComponent{}),
3030
reflect.TypeOf(&NodeComponent{}),
3131
}
3232
return requires
@@ -66,11 +66,11 @@ func (this *ChildComponent) DoReport() {
6666
})
6767
args := &NodeInfo{
6868
Address: this.localAddr,
69-
Role: Config.Config.ClusterConfig.Role,
70-
AppName: Config.Config.ClusterConfig.AppName,
69+
Role: config.Config.ClusterConfig.Role,
70+
AppName: config.Config.ClusterConfig.AppName,
7171
}
7272
var reply bool
73-
var interval = time.Duration(Config.Config.ClusterConfig.ReportInterval)
73+
var interval = time.Duration(config.Config.ClusterConfig.ReportInterval)
7474
for {
7575
reply = false
7676
this.locker.RLock()
@@ -112,7 +112,7 @@ func (this *ChildComponent) ReportClose(addr string) {
112112

113113
//连接到master
114114
func (this *ChildComponent) ConnectToMaster() {
115-
addr := Config.Config.ClusterConfig.MasterAddress
115+
addr := config.Config.ClusterConfig.MasterAddress
116116
callback := func(event string, data ...interface{}) {
117117
switch event {
118118
case "close":
@@ -126,7 +126,7 @@ func (this *ChildComponent) ConnectToMaster() {
126126
this.rpcMaster, err = this.nodeComponent.ConnectToNode(addr, callback)
127127
if err == nil {
128128
ip := strings.Split(this.rpcMaster.LocalAddr(), ":")[0]
129-
port := strings.Split(Config.Config.ClusterConfig.LocalAddress, ":")[1]
129+
port := strings.Split(config.Config.ClusterConfig.LocalAddress, ":")[1]
130130
this.localAddr = fmt.Sprintf("%s:%s", ip, port)
131131
this.locker.Unlock()
132132
break

cluster/LocationComponent.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Cluster
33
import (
44
"errors"
55
"github.com/zllangct/RockGO/component"
6-
"github.com/zllangct/RockGO/configComponent"
6+
"github.com/zllangct/RockGO/config"
77
"github.com/zllangct/RockGO/rpc"
88
"reflect"
99
"sync"
@@ -31,7 +31,7 @@ type LocationComponent struct {
3131
func (this *LocationComponent) GetRequire() map[*Component.Object][]reflect.Type {
3232
requires := make(map[*Component.Object][]reflect.Type)
3333
requires[this.Runtime().Root()] = []reflect.Type{
34-
reflect.TypeOf(&Config.ConfigComponent{}),
34+
reflect.TypeOf(&config.ConfigComponent{}),
3535
reflect.TypeOf(&NodeComponent{}),
3636
}
3737
return requires
@@ -57,11 +57,11 @@ func (this *LocationComponent) Awake(ctx *Component.Context) {
5757
//同步节点信息到位置服务组件
5858
func (this *LocationComponent) DoLocationSync() {
5959
var reply *NodeInfoSyncReply
60-
var interval = time.Duration(Config.Config.ClusterConfig.LocationSyncInterval)
60+
var interval = time.Duration(config.Config.ClusterConfig.LocationSyncInterval)
6161
for {
6262
if this.master == nil {
6363
var err error
64-
this.master, err = this.nodeComponent.GetNodeClient(Config.Config.ClusterConfig.MasterAddress)
64+
this.master, err = this.nodeComponent.GetNodeClient(config.Config.ClusterConfig.MasterAddress)
6565
if err != nil {
6666
time.Sleep(time.Second * interval)
6767
continue

cluster/MasterComponent.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Cluster
33
import (
44
"fmt"
55
"github.com/zllangct/RockGO/component"
6-
"github.com/zllangct/RockGO/configComponent"
6+
"github.com/zllangct/RockGO/config"
77
"github.com/zllangct/RockGO/logger"
88
"github.com/zllangct/RockGO/utils"
99
"reflect"
@@ -28,7 +28,7 @@ type MasterComponent struct {
2828
func (this *MasterComponent) GetRequire() map[*Component.Object][]reflect.Type {
2929
requires := make(map[*Component.Object][]reflect.Type)
3030
requires[this.Parent().Root()] = []reflect.Type{
31-
reflect.TypeOf(&Config.ConfigComponent{}),
31+
reflect.TypeOf(&config.ConfigComponent{}),
3232
reflect.TypeOf(&NodeComponent{}),
3333
}
3434
return requires
@@ -52,7 +52,7 @@ func (this *MasterComponent) Awake(ctx *Component.Context) {
5252
if err != nil {
5353
panic(err)
5454
}
55-
if !Config.Config.CommonConfig.Debug || false {
55+
if !config.Config.CommonConfig.Debug || false {
5656
go this.TimeoutCheck()
5757
}
5858
}
@@ -102,7 +102,7 @@ func (this *MasterComponent) NodeInquiry(args []string, detail bool) ([]*Inquiry
102102

103103
//检查超时节点
104104
func (this *MasterComponent) TimeoutCheck() map[string]*NodeInfo {
105-
var interval = time.Duration(Config.Config.ClusterConfig.ReportInterval)
105+
var interval = time.Duration(config.Config.ClusterConfig.ReportInterval)
106106
for {
107107
time.Sleep(time.Millisecond * interval)
108108
this.locker.Lock()

cluster/NodeComponent.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"github.com/zllangct/RockGO/component"
7-
"github.com/zllangct/RockGO/configComponent"
7+
"github.com/zllangct/RockGO/config"
88
"github.com/zllangct/RockGO/logger"
99
"github.com/zllangct/RockGO/rpc"
1010
"math/rand"
@@ -36,15 +36,15 @@ type NodeComponent struct {
3636
func (this *NodeComponent) GetRequire() map[*Component.Object][]reflect.Type {
3737
requires := make(map[*Component.Object][]reflect.Type)
3838
requires[this.Parent().Root()] = []reflect.Type{
39-
reflect.TypeOf(&Config.ConfigComponent{}),
39+
reflect.TypeOf(&config.ConfigComponent{}),
4040
}
4141
return requires
4242
}
4343

4444
func (this *NodeComponent) Initialize() error {
4545
logger.Info("NodeComponent init .....")
46-
this.AppName = Config.Config.ClusterConfig.AppName
47-
this.islocationMode = Config.Config.ClusterConfig.IsLocationMode
46+
this.AppName = config.Config.ClusterConfig.AppName
47+
this.islocationMode = config.Config.ClusterConfig.IsLocationMode
4848
this.clientGetting = make(map[string]int)
4949
//开始本节点RPC服务
5050
err := this.StartRpcServer()
@@ -72,7 +72,7 @@ func (this *NodeComponent) IsOnline() bool {
7272

7373
//获取位置服务器
7474
func (this *NodeComponent) InitLocationServerGetter() {
75-
if !Config.Config.ClusterConfig.IsLocationMode {
75+
if !config.Config.ClusterConfig.IsLocationMode {
7676
return
7777
}
7878
locker := sync.RWMutex{}
@@ -135,7 +135,7 @@ func (this *NodeComponent) locationBroken() {
135135

136136
//RPC服务
137137
func (this *NodeComponent) StartRpcServer() error {
138-
addr, err := net.ResolveTCPAddr("tcp", Config.Config.ClusterConfig.LocalAddress)
138+
addr, err := net.ResolveTCPAddr("tcp", config.Config.ClusterConfig.LocalAddress)
139139
if err != nil {
140140
return err
141141
}
@@ -274,7 +274,7 @@ func (this *NodeComponent) GetNodeFromLocation(role string, selectorType ...Sele
274274

275275
var reply *[]*InquiryReply
276276
args := []string{
277-
SELECTOR_TYPE_DEFAULT, Config.Config.ClusterConfig.AppName, role,
277+
SELECTOR_TYPE_DEFAULT, config.Config.ClusterConfig.AppName, role,
278278
}
279279
if len(selectorType) > 0 {
280280
args[0] = selectorType[0]
@@ -313,7 +313,7 @@ func (this *NodeComponent) GetNodeGroupFromLocation(role string) (*NodeIDGroup,
313313

314314
var reply *[]*InquiryReply
315315
args := []string{
316-
SELECTOR_TYPE_GROUP, Config.Config.ClusterConfig.AppName, role,
316+
SELECTOR_TYPE_GROUP, config.Config.ClusterConfig.AppName, role,
317317
}
318318
err = client.Call("LocationService.NodeInquiry", args, &reply)
319319
if err != nil {
@@ -332,13 +332,13 @@ func (this *NodeComponent) GetNodeFromMaster(role string, selectorType ...Select
332332
if !this.IsOnline() {
333333
return nil, ErrNodeOffline
334334
}
335-
client, err := this.GetNodeClient(Config.Config.ClusterConfig.MasterAddress)
335+
client, err := this.GetNodeClient(config.Config.ClusterConfig.MasterAddress)
336336
if err != nil {
337337
return nil, err
338338
}
339339
var reply *[]*InquiryReply
340340
args := []string{
341-
SELECTOR_TYPE_DEFAULT, Config.Config.ClusterConfig.AppName, role,
341+
SELECTOR_TYPE_DEFAULT, config.Config.ClusterConfig.AppName, role,
342342
}
343343
if len(selectorType) > 0 {
344344
args[0] = selectorType[0]
@@ -363,13 +363,13 @@ func (this *NodeComponent) GetNodeGroupFromMaster(role string) (*NodeIDGroup, er
363363
if !this.IsOnline() {
364364
return nil, ErrNodeOffline
365365
}
366-
client, err := this.GetNodeClient(Config.Config.ClusterConfig.MasterAddress)
366+
client, err := this.GetNodeClient(config.Config.ClusterConfig.MasterAddress)
367367
if err != nil {
368368
return nil, err
369369
}
370370
var reply *[]*InquiryReply
371371
args := []string{
372-
SELECTOR_TYPE_GROUP, Config.Config.ClusterConfig.AppName, role,
372+
SELECTOR_TYPE_GROUP, config.Config.ClusterConfig.AppName, role,
373373
}
374374
err = client.Call("MasterService.NodeInquiry", args, &reply)
375375
if err != nil {
File renamed without changes.
File renamed without changes.

configComponent/ConfigComponent.go config/ConfigComponent.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package Config
1+
package config
22

33
import (
44
"encoding/json"
@@ -29,8 +29,8 @@ func (this *ConfigComponent) IsUnique() int {
2929
}
3030

3131
func (this *ConfigComponent) Initialize() error {
32-
this.commonConfigPath = "./config/CommonConfig.json"
33-
this.clusterConfigPath = "./config/ClusterConfig.json"
32+
this.commonConfigPath = "./conf/CommonConfig.json"
33+
this.clusterConfigPath = "./conf/ClusterConfig.json"
3434
//初始化默认配置
3535
this.SetDefault()
3636
//读取配置文件
@@ -88,7 +88,7 @@ func (this *ConfigComponent) ReloadConfig() {
8888
}
8989
}
9090

91-
// configComponent.CustomConfig[name] = structure
91+
// config.CustomConfig[name] = structure
9292
func (this *ConfigComponent) LoadCustomConfig(path string, structure interface{}) (err error) {
9393
kind := reflect.TypeOf(structure).Kind()
9494
if kind != reflect.Ptr && kind != reflect.Map {

example/ComponentTemplate/template.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/zllangct/RockGO/actor"
55
"github.com/zllangct/RockGO/cluster"
66
"github.com/zllangct/RockGO/component"
7-
"github.com/zllangct/RockGO/configComponent"
7+
"github.com/zllangct/RockGO/config"
88
"github.com/zllangct/RockGO/logger"
99
"reflect"
1010
"sync"
@@ -30,7 +30,7 @@ func (this *TemplateComponent) IsUnique() int {
3030
func (this *TemplateComponent) GetRequire() map[*Component.Object][]reflect.Type {
3131
requires := make(map[*Component.Object][]reflect.Type)
3232
requires[this.Root()] = []reflect.Type{
33-
reflect.TypeOf(&Config.ConfigComponent{}), //依赖根对象拥有ConfigComponent组件
33+
reflect.TypeOf(&config.ConfigComponent{}), //依赖根对象拥有ConfigComponent组件
3434
reflect.TypeOf(&Cluster.NodeComponent{}), //依赖根对象拥有NodeComponent组件
3535
}
3636
/*

example/SingleNode/LoginComponent.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"github.com/zllangct/RockGO/cluster"
66
"github.com/zllangct/RockGO/component"
7-
"github.com/zllangct/RockGO/configComponent"
7+
"github.com/zllangct/RockGO/config"
88
"reflect"
99
"sync"
1010
"time"
@@ -20,7 +20,7 @@ type LoginComponent struct {
2020
func (this *LoginComponent) GetRequire() map[*Component.Object][]reflect.Type {
2121
requires := make(map[*Component.Object][]reflect.Type)
2222
requires[this.Root()] = []reflect.Type{
23-
reflect.TypeOf(&Config.ConfigComponent{}),
23+
reflect.TypeOf(&config.ConfigComponent{}),
2424
}
2525
return requires
2626
}

gate/DefaultGateComponent.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"github.com/zllangct/RockGO/cluster"
77
"github.com/zllangct/RockGO/component"
8-
"github.com/zllangct/RockGO/configComponent"
8+
"github.com/zllangct/RockGO/config"
99
"github.com/zllangct/RockGO/logger"
1010
"github.com/zllangct/RockGO/network"
1111
"reflect"
@@ -29,7 +29,7 @@ func (this *DefaultGateComponent) IsUnique() int {
2929
func (this *DefaultGateComponent) GetRequire() map[*Component.Object][]reflect.Type {
3030
requires := make(map[*Component.Object][]reflect.Type)
3131
requires[this.Parent().Root()] = []reflect.Type{
32-
reflect.TypeOf(&Config.ConfigComponent{}),
32+
reflect.TypeOf(&config.ConfigComponent{}),
3333
}
3434
return requires
3535
}
@@ -46,8 +46,8 @@ func (this *DefaultGateComponent) Awake(ctx *Component.Context) {
4646
conf := &network.ServerConf{
4747
Proto: "ws",
4848
PackageProtocol: &network.TdProtocol{},
49-
Address: Config.Config.ClusterConfig.NetListenAddress,
50-
ReadTimeout: time.Millisecond * time.Duration(Config.Config.ClusterConfig.NetConnTimeout),
49+
Address: config.Config.ClusterConfig.NetListenAddress,
50+
ReadTimeout: time.Millisecond * time.Duration(config.Config.ClusterConfig.NetConnTimeout),
5151
OnClientDisconnected: this.OnDropped,
5252
OnClientConnected: this.OnConnected,
5353
NetAPI: this.NetAPI,

0 commit comments

Comments
 (0)