Commit 7fd7ad91 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

fix

parent 2235285a
...@@ -20,7 +20,6 @@ type Pool struct { ...@@ -20,7 +20,6 @@ type Pool struct {
slavesIter *atomic.Int64 slavesIter *atomic.Int64
slavesAsyncIter *atomic.Int64 slavesAsyncIter *atomic.Int64
stop bool
Continues []string Continues []string
ContinuesTry []string ContinuesTry []string
TryOnError int TryOnError int
...@@ -45,7 +44,6 @@ func (d *Pool) WithContext(ctx context.Context) *Pool { ...@@ -45,7 +44,6 @@ func (d *Pool) WithContext(ctx context.Context) *Pool {
notAliveConns: d.notAliveConns, notAliveConns: d.notAliveConns,
slavesIter: d.slavesIter, slavesIter: d.slavesIter,
slavesAsyncIter: d.slavesAsyncIter, slavesAsyncIter: d.slavesAsyncIter,
stop: d.stop,
Continues: d.Continues, Continues: d.Continues,
ContinuesTry: d.ContinuesTry, ContinuesTry: d.ContinuesTry,
TryOnError: d.TryOnError, TryOnError: d.TryOnError,
...@@ -282,14 +280,9 @@ func (d *Pool) setNotAliveConn(conn *Conn) { ...@@ -282,14 +280,9 @@ func (d *Pool) setNotAliveConn(conn *Conn) {
} }
} }
func (d *Pool) Start() { func (d *Pool) startPing() {
d.stop = false
go func() { go func() {
for { for {
if d.stop {
return
}
rep: rep:
for i, q := range d.notAliveConns { for i, q := range d.notAliveConns {
...@@ -317,10 +310,6 @@ func (d *Pool) Start() { ...@@ -317,10 +310,6 @@ func (d *Pool) Start() {
}() }()
} }
func (d *Pool) Stop() {
d.stop = true
}
func (d *Pool) IsAlive() bool { func (d *Pool) IsAlive() bool {
return d.SrvMaster != nil && d.SrvMaster.Alive return d.SrvMaster != nil && d.SrvMaster.Alive
} }
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
) )
func New(ctx context.Context) *Pool { func New(ctx context.Context) *Pool {
return &Pool{ p := &Pool{
ctx: ctx, ctx: ctx,
mu: &sync.RWMutex{}, mu: &sync.RWMutex{},
slavesIter: &atomic.Int64{}, slavesIter: &atomic.Int64{},
...@@ -21,6 +21,9 @@ func New(ctx context.Context) *Pool { ...@@ -21,6 +21,9 @@ func New(ctx context.Context) *Pool {
PingTimeout: time.Second * 5, PingTimeout: time.Second * 5,
PingTry: 5, PingTry: 5,
} }
p.startPing()
return p
} }
func NewDefault() *Pool { func NewDefault() *Pool {
...@@ -33,7 +36,6 @@ func NewDefault() *Pool { ...@@ -33,7 +36,6 @@ func NewDefault() *Pool {
func NewMaster(conn string) *Pool { func NewMaster(conn string) *Pool {
s := NewDefault() s := NewDefault()
_ = s.NewConn(ConnModeMaster, conn) _ = s.NewConn(ConnModeMaster, conn)
s.Start()
return s return s
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment