@@ -9,10 +9,6 @@ import (
99 "time"
1010)
1111
12- var onceInit sync.Once
13- var onceMonitor sync.Once
14- var instance * AddressPool
15-
1612const (
1713 available string = "available"
1814 unavailable string = "unavailable"
@@ -21,22 +17,19 @@ const (
2117
2218// AddressPool registry address pool
2319type AddressPool struct {
24- protocol string
25- addressMap map [string ]string
26- status map [string ]string
27- mutex sync.RWMutex
20+ protocol string
21+ addressMap map [string ]string
22+ status map [string ]string
23+ mutex sync.RWMutex
24+ onceMonitor sync.Once
2825}
2926
3027// NewPool Get registry pool instance
3128func NewPool (protocol string ) * AddressPool {
32- onceInit .Do (func () {
33- instance = & AddressPool {
34- protocol : protocol ,
35- addressMap : make (map [string ]string ),
36- status : make (map [string ]string ),
37- }
38- })
39- return instance
29+ return & AddressPool {
30+ addressMap : make (map [string ]string ),
31+ status : make (map [string ]string ),
32+ }
4033}
4134
4235// SetAddress set addresses to pool
@@ -89,7 +82,7 @@ func (p *AddressPool) checkConnectivity() {
8982
9083//Monitor monitor each service center network connectivity
9184func (p * AddressPool ) Monitor () {
92- onceMonitor .Do (func () {
85+ p . onceMonitor .Do (func () {
9386 p .checkConnectivity ()
9487 var interval time.Duration
9588 v , isExist := os .LookupEnv (EnvCheckSCIInterval )
0 commit comments