4
4
"errors"
5
5
"fmt"
6
6
"github.com/zllangct/RockGO/component"
7
- "github.com/zllangct/RockGO/configComponent "
7
+ "github.com/zllangct/RockGO/config "
8
8
"github.com/zllangct/RockGO/logger"
9
9
"github.com/zllangct/RockGO/rpc"
10
10
"math/rand"
@@ -36,15 +36,15 @@ type NodeComponent struct {
36
36
func (this * NodeComponent ) GetRequire () map [* Component.Object ][]reflect.Type {
37
37
requires := make (map [* Component.Object ][]reflect.Type )
38
38
requires [this .Parent ().Root ()] = []reflect.Type {
39
- reflect .TypeOf (& Config .ConfigComponent {}),
39
+ reflect .TypeOf (& config .ConfigComponent {}),
40
40
}
41
41
return requires
42
42
}
43
43
44
44
func (this * NodeComponent ) Initialize () error {
45
45
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
48
48
this .clientGetting = make (map [string ]int )
49
49
//开始本节点RPC服务
50
50
err := this .StartRpcServer ()
@@ -72,7 +72,7 @@ func (this *NodeComponent) IsOnline() bool {
72
72
73
73
//获取位置服务器
74
74
func (this * NodeComponent ) InitLocationServerGetter () {
75
- if ! Config .Config .ClusterConfig .IsLocationMode {
75
+ if ! config .Config .ClusterConfig .IsLocationMode {
76
76
return
77
77
}
78
78
locker := sync.RWMutex {}
@@ -135,7 +135,7 @@ func (this *NodeComponent) locationBroken() {
135
135
136
136
//RPC服务
137
137
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 )
139
139
if err != nil {
140
140
return err
141
141
}
@@ -274,7 +274,7 @@ func (this *NodeComponent) GetNodeFromLocation(role string, selectorType ...Sele
274
274
275
275
var reply * []* InquiryReply
276
276
args := []string {
277
- SELECTOR_TYPE_DEFAULT , Config .Config .ClusterConfig .AppName , role ,
277
+ SELECTOR_TYPE_DEFAULT , config .Config .ClusterConfig .AppName , role ,
278
278
}
279
279
if len (selectorType ) > 0 {
280
280
args [0 ] = selectorType [0 ]
@@ -313,7 +313,7 @@ func (this *NodeComponent) GetNodeGroupFromLocation(role string) (*NodeIDGroup,
313
313
314
314
var reply * []* InquiryReply
315
315
args := []string {
316
- SELECTOR_TYPE_GROUP , Config .Config .ClusterConfig .AppName , role ,
316
+ SELECTOR_TYPE_GROUP , config .Config .ClusterConfig .AppName , role ,
317
317
}
318
318
err = client .Call ("LocationService.NodeInquiry" , args , & reply )
319
319
if err != nil {
@@ -332,13 +332,13 @@ func (this *NodeComponent) GetNodeFromMaster(role string, selectorType ...Select
332
332
if ! this .IsOnline () {
333
333
return nil , ErrNodeOffline
334
334
}
335
- client , err := this .GetNodeClient (Config .Config .ClusterConfig .MasterAddress )
335
+ client , err := this .GetNodeClient (config .Config .ClusterConfig .MasterAddress )
336
336
if err != nil {
337
337
return nil , err
338
338
}
339
339
var reply * []* InquiryReply
340
340
args := []string {
341
- SELECTOR_TYPE_DEFAULT , Config .Config .ClusterConfig .AppName , role ,
341
+ SELECTOR_TYPE_DEFAULT , config .Config .ClusterConfig .AppName , role ,
342
342
}
343
343
if len (selectorType ) > 0 {
344
344
args [0 ] = selectorType [0 ]
@@ -363,13 +363,13 @@ func (this *NodeComponent) GetNodeGroupFromMaster(role string) (*NodeIDGroup, er
363
363
if ! this .IsOnline () {
364
364
return nil , ErrNodeOffline
365
365
}
366
- client , err := this .GetNodeClient (Config .Config .ClusterConfig .MasterAddress )
366
+ client , err := this .GetNodeClient (config .Config .ClusterConfig .MasterAddress )
367
367
if err != nil {
368
368
return nil , err
369
369
}
370
370
var reply * []* InquiryReply
371
371
args := []string {
372
- SELECTOR_TYPE_GROUP , Config .Config .ClusterConfig .AppName , role ,
372
+ SELECTOR_TYPE_GROUP , config .Config .ClusterConfig .AppName , role ,
373
373
}
374
374
err = client .Call ("MasterService.NodeInquiry" , args , & reply )
375
375
if err != nil {
0 commit comments