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
86d85eca
Commit
86d85eca
authored
1 year ago
by
Vladimir Barsukov
Browse files
Options
Download
Email Patches
Plain Diff
fix
parent
5b2da0e8
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
v1.2.1
v1.2.0
v1.1.1
v1.1.0
v1.0.9
v1.0.8
v1.0.7
v1.0.6
v1.0.5
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
zdb/pool.go
+12
-4
zdb/pool.go
zdebug/zdebug.go
+2
-2
zdebug/zdebug.go
zquit/pool.go
+2
-2
zquit/pool.go
zquit/zquit.go
+2
-2
zquit/zquit.go
with
18 additions
and
10 deletions
+18
-10
zdb/pool.go
+
12
-
4
View file @
86d85eca
...
...
@@ -2,7 +2,6 @@ package zdb
import
(
"context"
"errors"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
"log"
...
...
@@ -86,13 +85,22 @@ func (d *Pool) WithContext(ctx context.Context) *Pool {
}
func
(
d
*
Pool
)
WithTimeout
(
dur
time
.
Duration
)
*
Pool
{
ctx
,
_
:=
context
.
WithTimeout
(
d
.
ctx
,
dur
)
ctx
,
cancel
:=
context
.
WithTimeout
(
d
.
ctx
,
dur
)
go
func
()
{
time
.
Sleep
(
dur
)
cancel
()
}()
return
d
.
WithContext
(
ctx
)
}
func
(
d
*
Pool
)
WithDeadline
(
dur
time
.
Time
)
*
Pool
{
ctx
,
_
:=
context
.
WithDeadline
(
d
.
ctx
,
dur
)
ctx
,
cancel
:=
context
.
WithDeadline
(
d
.
ctx
,
dur
)
go
func
()
{
time
.
Sleep
(
time
.
Since
(
dur
))
cancel
()
}()
return
d
.
WithContext
(
ctx
)
}
...
...
@@ -113,7 +121,7 @@ func (d *Pool) NewConn(mode connMode, pgConnString string) error {
q
.
Index
=
len
(
d
.
SrvAsync
)
d
.
SrvAsync
=
append
(
d
.
SrvAsync
,
q
)
default
:
return
errors
.
New
(
"unknown mode"
)
panic
(
"unknown mode"
)
}
return
err
...
...
This diff is collapsed.
Click to expand it.
zdebug/zdebug.go
+
2
-
2
View file @
86d85eca
...
...
@@ -14,14 +14,14 @@ func NewMonitor(secs int) {
var
memMax
uint64
for
{
<-
time
.
After
(
time
.
Duration
(
secs
)
*
time
.
Second
)
time
.
Sleep
(
time
.
Duration
(
secs
)
*
time
.
Second
)
runtime
.
ReadMemStats
(
&
rtm
)
mem
:=
((
rtm
.
HeapIdle
-
rtm
.
HeapReleased
)
+
(
rtm
.
Alloc
+
rtm
.
HeapInuse
))
/
1e6
memMax
=
max
(
memMax
,
mem
)
fmt
.
Printf
(
"Z
_
DEBUG: MEM: %v; MEM_MAX: %v; OBJ: %v, GO: %v, GC: %v
\n
"
,
fmt
.
Printf
(
"ZDEBUG: MEM: %v; MEM_MAX: %v; OBJ: %v, GO: %v, GC: %v
\n
"
,
mem
,
memMax
,
(
rtm
.
Mallocs
-
rtm
.
Frees
)
/
1e3
,
...
...
This diff is collapsed.
Click to expand it.
zquit/pool.go
+
2
-
2
View file @
86d85eca
...
...
@@ -32,13 +32,13 @@ func (p *Pool) Add(z *ZQuit) {
func
(
p
*
Pool
)
PrintStat
(
sec
int
)
{
go
func
()
{
for
{
<-
time
.
After
(
time
.
Second
*
time
.
Duration
(
sec
))
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
sec
))
s
:=
""
for
_
,
i
:=
range
p
.
items
{
s
+=
i
.
GetStat
()
+
"; "
}
log
.
Printf
(
"Z
_
QUIT: %s"
,
s
)
log
.
Printf
(
"ZQUIT: %s"
,
s
)
}
}()
}
...
...
This diff is collapsed.
Click to expand it.
zquit/zquit.go
+
2
-
2
View file @
86d85eca
...
...
@@ -101,8 +101,8 @@ func (q *ZQuit) GetStat() string {
func
(
q
*
ZQuit
)
PrintStat
(
sec
int
)
{
go
func
()
{
for
{
<-
time
.
After
(
time
.
Second
*
time
.
Duration
(
sec
))
log
.
Printf
(
"Z
_
QUIT: %s"
,
q
.
GetStat
())
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
sec
))
log
.
Printf
(
"ZQUIT: %s"
,
q
.
GetStat
())
}
}()
}
...
...
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