Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
1 year ago
by
Vladimir Barsukov
Browse files
Options
Download
Email Patches
Plain Diff
zdb NewMaster
parent
02d4612b
master
v1.6.4
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.1
v1.3.0
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
zdb/pool.go
+0
-24
zdb/pool.go
zdb/zdb.go
+40
-0
zdb/zdb.go
with
40 additions
and
24 deletions
+40
-24
zdb/pool.go
+
0
-
24
View file @
168e879e
...
...
@@ -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
,
...
...
This diff is collapsed.
Click to expand it.
zdb/zdb.go
0 → 100644
+
40
-
0
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
}
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets