good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pggat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gfx
pggat
Commits
a83b6a66
Commit
a83b6a66
authored
2 years ago
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
i hate races
parent
fa64fbdf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config_data.yml
+1
-1
1 addition, 1 deletion
config_data.yml
lib/gat/gatling/gatling.go
+11
-6
11 additions, 6 deletions
lib/gat/gatling/gatling.go
lib/gat/pool/session/pool.go
+7
-0
7 additions, 0 deletions
lib/gat/pool/session/pool.go
with
19 additions
and
7 deletions
config_data.yml
+
1
−
1
View file @
a83b6a66
...
...
@@ -13,7 +13,7 @@ general:
admin_password
:
postgres
pools
:
simple_db
:
pool_mode
:
sess
ion
pool_mode
:
transact
ion
default_role
:
primary
query_parser_enabled
:
true
primary_reads_enabled
:
true
...
...
This diff is collapsed.
Click to expand it.
lib/gat/gatling/gatling.go
+
11
−
6
View file @
a83b6a66
...
...
@@ -153,20 +153,25 @@ func (g *Gatling) ListenAndServe(ctx context.Context) error {
}
go
func
()
{
for
{
var
c
net
.
Conn
c
,
err
=
ln
.
Accept
()
if
err
!=
nil
{
log
.
Println
(
"failed to accept connection:"
,
err
)
}
errch
:=
make
(
chan
error
)
go
func
()
{
c
,
err
:=
ln
.
Accept
()
if
err
!=
nil
{
errch
<-
err
}
close
(
errch
)
err
=
g
.
handleConnection
(
ctx
,
c
)
if
err
!=
nil
{
if
err
!=
io
.
EOF
{
log
.
Println
(
"disconnected:"
,
err
)
}
return
}
}()
err
=
<-
errch
if
err
!=
nil
{
log
.
Println
(
"failed to accept connection:"
,
err
)
}
}
}()
return
nil
...
...
This diff is collapsed.
Click to expand it.
lib/gat/pool/session/pool.go
+
7
−
0
View file @
a83b6a66
...
...
@@ -6,6 +6,7 @@ import (
"gfx.cafe/gfx/pggat/lib/gat"
"gfx.cafe/gfx/pggat/lib/gat/protocol"
"runtime"
"sync"
"sync/atomic"
)
...
...
@@ -19,6 +20,8 @@ type Pool struct {
assigned
map
[
gat
.
ClientID
]
gat
.
Connection
servers
chan
gat
.
Connection
mu
sync
.
Mutex
}
func
New
(
database
gat
.
Database
,
dialer
gat
.
Dialer
,
conf
*
config
.
Pool
,
user
*
config
.
User
)
*
Pool
{
...
...
@@ -52,6 +55,8 @@ func (p *Pool) returnConnection(c gat.Connection) {
}
func
(
p
*
Pool
)
getOrAssign
(
client
gat
.
Client
)
gat
.
Connection
{
p
.
mu
.
Lock
()
defer
p
.
mu
.
Unlock
()
cid
:=
client
.
GetId
()
c
,
ok
:=
p
.
assigned
[
cid
]
if
!
ok
{
...
...
@@ -71,6 +76,8 @@ func (p *Pool) EnsureConfig(c *config.Pool) {
}
func
(
p
*
Pool
)
OnDisconnect
(
client
gat
.
Client
)
{
p
.
mu
.
Lock
()
defer
p
.
mu
.
Unlock
()
cid
:=
client
.
GetId
()
c
,
ok
:=
p
.
assigned
[
cid
]
if
!
ok
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment