Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
168e879e
Commit
168e879e
authored
Mar 06, 2024
by
Vladimir Barsukov
Browse files
zdb NewMaster
parent
02d4612b
Changes
2
Hide whitespace changes
Inline
Side-by-side
zdb/pool.go
View file @
168e879e
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"context"
"context"
"fmt"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/jackc/pgx/v5/pgxpool"
"log"
"reflect"
"reflect"
"runtime"
"runtime"
"strconv"
"strconv"
...
@@ -41,29 +40,6 @@ type Pool struct {
...
@@ -41,29 +40,6 @@ type Pool struct {
PingTry
int
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
{
func
(
d
*
Pool
)
WithContext
(
ctx
context
.
Context
)
*
Pool
{
return
&
Pool
{
return
&
Pool
{
ctx
:
ctx
,
ctx
:
ctx
,
...
...
zdb/zdb.go
0 → 100644
View file @
168e879e
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
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment