Commit 63993088 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

save

parent 5afc3dc5
Pipeline #41 canceled with stages
...@@ -27,6 +27,8 @@ type Pool struct { ...@@ -27,6 +27,8 @@ type Pool struct {
slavesIter *atomic.Int64 slavesIter *atomic.Int64
slavesAsyncIter *atomic.Int64 slavesAsyncIter *atomic.Int64
stop bool
} }
func New() *Pool { func New() *Pool {
...@@ -188,9 +190,15 @@ func (d *Pool) setNotAliveConn(conn *conn) { ...@@ -188,9 +190,15 @@ func (d *Pool) setNotAliveConn(conn *conn) {
} }
} }
func (d *Pool) Test() { func (d *Pool) Start() {
d.stop = false
go func() { go func() {
for { for {
if d.stop {
return
}
for i, q := range d.notAliveConns { for i, q := range d.notAliveConns {
if err := d.ping(q); err == nil { if err := d.ping(q); err == nil {
d.mu.Lock() d.mu.Lock()
...@@ -212,6 +220,10 @@ func (d *Pool) Test() { ...@@ -212,6 +220,10 @@ func (d *Pool) Test() {
}() }()
} }
func (d *Pool) Stop() {
d.stop = true
}
func (d *Pool) prepare(sql string, param map[string]any) string { func (d *Pool) prepare(sql string, param map[string]any) string {
for n, t := range param { for n, t := range param {
switch t.(type) { switch t.(type) {
......
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