Commit 168e879e authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

zdb NewMaster

parent 02d4612b
......@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
"log"
"reflect"
"runtime"
"strconv"
......@@ -41,29 +40,6 @@ type Pool struct {
PingTry int
}
func New(ctx context.Context) *Pool {
return &Pool{
ctx: ctx,
mu: &sync.RWMutex{},
slavesIter: &atomic.Int64{},
slavesAsyncIter: &atomic.Int64{},
Continues: []string{"connect", "EOF", "conflict with recovery", "context deadline exceeded"},
ContinuesTry: []string{"conflict with recovery"},
TryOnError: 1,
TryOnSleep: time.Second,
Balance: BalanceLeastConn,
PingTimout: time.Second * 5,
PingTry: 5,
}
}
func NewDefault() *Pool {
p := New(context.Background())
p.logger = log.Default()
return p
}
func (d *Pool) WithContext(ctx context.Context) *Pool {
return &Pool{
ctx: ctx,
......
package zdb
import (
"context"
"log"
"sync"
"sync/atomic"
"time"
)
func New(ctx context.Context) *Pool {
return &Pool{
ctx: ctx,
mu: &sync.RWMutex{},
slavesIter: &atomic.Int64{},
slavesAsyncIter: &atomic.Int64{},
Continues: []string{"connect", "EOF", "conflict with recovery", "context deadline exceeded"},
ContinuesTry: []string{"conflict with recovery"},
TryOnError: 1,
TryOnSleep: time.Second,
Balance: BalanceLeastConn,
PingTimout: time.Second * 5,
PingTry: 5,
}
}
func NewDefault() *Pool {
p := New(context.Background())
p.logger = log.Default()
return p
}
func NewMaster(conn string) *Pool {
s := NewDefault()
_ = s.NewConn(ConnModeMaster, conn)
s.Start()
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