File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ type Pool struct {
35
35
36
36
status map [string ]string
37
37
onceMonitor sync.Once
38
+ quit chan struct {}
39
+ onceQuit sync.Once
40
+ }
41
+
42
+ func (p * Pool ) Close () {
43
+ p .onceQuit .Do (func () {
44
+ close (p .quit )
45
+ })
38
46
}
39
47
40
48
// NewPool Get registry pool instance
@@ -57,6 +65,16 @@ func (p *Pool) appendAddressToStatus(addresses []string) {
57
65
}
58
66
}
59
67
68
+ func (p * Pool ) ResetAddress (addresses []string ) {
69
+ p .mutex .Lock ()
70
+ defer p .mutex .Unlock ()
71
+ p .defaultAddress = removeDuplicates (addresses )
72
+ p .diffAzAddress = []string {}
73
+ p .sameAzAddress = []string {}
74
+ p .status = make (map [string ]string )
75
+ p .appendAddressToStatus (addresses )
76
+ }
77
+
60
78
func (p * Pool ) SetAddressByInstances (instances []* discovery.MicroServiceInstance ) error {
61
79
p .mutex .Lock ()
62
80
defer p .mutex .Unlock ()
@@ -179,14 +197,14 @@ func (p *Pool) monitor() {
179
197
}
180
198
}
181
199
ticker := time .NewTicker (interval * time .Second )
182
- quit : = make (chan struct {})
200
+ p . quit = make (chan struct {})
183
201
184
202
go func () {
185
203
for {
186
204
select {
187
205
case <- ticker .C :
188
206
p .checkConnectivity ()
189
- case <- quit :
207
+ case <- p . quit :
190
208
ticker .Stop ()
191
209
return
192
210
}
You can’t perform that action at this time.
0 commit comments