Skip to content

Commit

Permalink
Update pool.go (#55)
Browse files Browse the repository at this point in the history
* Update pool.go

修复new多个client时底层共用一个pool导致所有client的ip相同问题

* Update golangci-lint.yml

升级golint到1.48.0

* Update pool.go

删除无用代码
  • Loading branch information
Yanxinyuanlalala authored Aug 18, 2022
1 parent dacdd0c commit e733ed9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.45.2
args: --skip-dirs=examples --skip-files=.*_test.go$
version: v1.48.0
args: --skip-dirs=examples --skip-files=.*_test.go$
27 changes: 10 additions & 17 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
"time"
)

var onceInit sync.Once
var onceMonitor sync.Once
var instance *AddressPool

const (
available string = "available"
unavailable string = "unavailable"
Expand All @@ -21,22 +17,19 @@ const (

// AddressPool registry address pool
type AddressPool struct {
protocol string
addressMap map[string]string
status map[string]string
mutex sync.RWMutex
protocol string
addressMap map[string]string
status map[string]string
mutex sync.RWMutex
onceMonitor sync.Once
}

// NewPool Get registry pool instance
func NewPool(protocol string) *AddressPool {
onceInit.Do(func() {
instance = &AddressPool{
protocol: protocol,
addressMap: make(map[string]string),
status: make(map[string]string),
}
})
return instance
return &AddressPool{
addressMap: make(map[string]string),
status: make(map[string]string),
}
}

// SetAddress set addresses to pool
Expand Down Expand Up @@ -89,7 +82,7 @@ func (p *AddressPool) checkConnectivity() {

//Monitor monitor each service center network connectivity
func (p *AddressPool) Monitor() {
onceMonitor.Do(func() {
p.onceMonitor.Do(func() {
p.checkConnectivity()
var interval time.Duration
v, isExist := os.LookupEnv(EnvCheckSCIInterval)
Expand Down

0 comments on commit e733ed9

Please sign in to comment.