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
27ecdeeb
Commit
27ecdeeb
authored
1 year ago
by
Garet Halliday
Browse files
Options
Downloads
Patches
Plain Diff
handle async operations
parent
73cdafb1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/bouncer/bouncers/v1/bouncer.go
+27
-10
27 additions, 10 deletions
lib/bouncer/bouncers/v1/bouncer.go
with
27 additions
and
10 deletions
lib/bouncer/bouncers/v1/bouncer.go
+
27
−
10
View file @
27ecdeeb
...
@@ -9,6 +9,27 @@ import (
...
@@ -9,6 +9,27 @@ import (
packets
"pggat2/lib/zap/packets/v3.0"
packets
"pggat2/lib/zap/packets/v3.0"
)
)
// serverRead is a wrapper for bctx.Context's ServerRead but it handles async operations
func
serverRead
(
ctx
*
bctx
.
Context
)
(
zap
.
In
,
berr
.
Error
)
{
for
{
in
,
err
:=
ctx
.
ServerRead
()
if
err
!=
nil
{
return
zap
.
In
{},
err
}
switch
in
.
Type
()
{
case
packets
.
NoticeResponse
,
packets
.
ParameterStatus
,
packets
.
NotificationResponse
:
err
=
ctx
.
ClientProxy
(
in
)
if
err
!=
nil
{
return
zap
.
In
{},
err
}
default
:
return
in
,
nil
}
}
}
func
readyForQuery
(
ctx
*
bctx
.
Context
,
in
zap
.
In
)
berr
.
Error
{
func
readyForQuery
(
ctx
*
bctx
.
Context
,
in
zap
.
In
)
berr
.
Error
{
state
,
ok
:=
packets
.
ReadReadyForQuery
(
in
)
state
,
ok
:=
packets
.
ReadReadyForQuery
(
in
)
if
!
ok
{
if
!
ok
{
...
@@ -51,7 +72,7 @@ func copyIn(ctx *bctx.Context) berr.Error {
...
@@ -51,7 +72,7 @@ func copyIn(ctx *bctx.Context) berr.Error {
}
}
func
copyOut0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
func
copyOut0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
in
,
err
:=
ctx
.
S
erverRead
()
in
,
err
:=
s
erverRead
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -83,7 +104,7 @@ func copyOut(ctx *bctx.Context) berr.Error {
...
@@ -83,7 +104,7 @@ func copyOut(ctx *bctx.Context) berr.Error {
}
}
func
query0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
func
query0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
in
,
err
:=
ctx
.
S
erverRead
()
in
,
err
:=
s
erverRead
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -93,9 +114,7 @@ func query0(ctx *bctx.Context) berr.Error {
...
@@ -93,9 +114,7 @@ func query0(ctx *bctx.Context) berr.Error {
packets
.
RowDescription
,
packets
.
RowDescription
,
packets
.
DataRow
,
packets
.
DataRow
,
packets
.
EmptyQueryResponse
,
packets
.
EmptyQueryResponse
,
packets
.
ErrorResponse
,
packets
.
ErrorResponse
:
packets
.
NoticeResponse
,
packets
.
ParameterStatus
:
return
ctx
.
ClientProxy
(
in
)
return
ctx
.
ClientProxy
(
in
)
case
packets
.
CopyInResponse
:
case
packets
.
CopyInResponse
:
err
=
ctx
.
ClientProxy
(
in
)
err
=
ctx
.
ClientProxy
(
in
)
...
@@ -137,13 +156,13 @@ func query(ctx *bctx.Context) berr.Error {
...
@@ -137,13 +156,13 @@ func query(ctx *bctx.Context) berr.Error {
}
}
func
functionCall0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
func
functionCall0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
in
,
err
:=
ctx
.
S
erverRead
()
in
,
err
:=
s
erverRead
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
switch
in
.
Type
()
{
switch
in
.
Type
()
{
case
packets
.
ErrorResponse
,
packets
.
FunctionCallResponse
,
packets
.
NoticeResponse
:
case
packets
.
ErrorResponse
,
packets
.
FunctionCallResponse
:
return
ctx
.
ClientProxy
(
in
)
return
ctx
.
ClientProxy
(
in
)
case
packets
.
ReadyForQuery
:
case
packets
.
ReadyForQuery
:
err
=
ctx
.
ClientProxy
(
in
)
err
=
ctx
.
ClientProxy
(
in
)
...
@@ -173,7 +192,7 @@ func functionCall(ctx *bctx.Context) berr.Error {
...
@@ -173,7 +192,7 @@ func functionCall(ctx *bctx.Context) berr.Error {
}
}
func
sync0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
func
sync0
(
ctx
*
bctx
.
Context
)
berr
.
Error
{
in
,
err
:=
ctx
.
S
erverRead
()
in
,
err
:=
s
erverRead
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -189,8 +208,6 @@ func sync0(ctx *bctx.Context) berr.Error {
...
@@ -189,8 +208,6 @@ func sync0(ctx *bctx.Context) berr.Error {
packets
.
CommandComplete
,
packets
.
CommandComplete
,
packets
.
DataRow
,
packets
.
DataRow
,
packets
.
EmptyQueryResponse
,
packets
.
EmptyQueryResponse
,
packets
.
NoticeResponse
,
packets
.
ParameterStatus
,
packets
.
PortalSuspended
:
packets
.
PortalSuspended
:
return
ctx
.
ClientProxy
(
in
)
return
ctx
.
ClientProxy
(
in
)
case
packets
.
ReadyForQuery
:
case
packets
.
ReadyForQuery
:
...
...
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