Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
01f84dc5
Unverified
Commit
01f84dc5
authored
5 years ago
by
Xin.Zh
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #302 from fangyincheng/heartbeat_for_server
Imp: receive heartbeat from server
parents
c6f6377e
53bb7fb4
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
protocol/dubbo/codec.go
+10
-4
10 additions, 4 deletions
protocol/dubbo/codec.go
protocol/dubbo/listener.go
+15
-9
15 additions, 9 deletions
protocol/dubbo/listener.go
protocol/dubbo/readwriter.go
+4
-2
4 additions, 2 deletions
protocol/dubbo/readwriter.go
with
29 additions
and
15 deletions
protocol/dubbo/codec.go
+
10
−
4
View file @
01f84dc5
...
...
@@ -89,11 +89,17 @@ func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error {
return
perrors
.
Errorf
(
"opts[0] is not of type *Client"
)
}
pendingRsp
,
ok
:=
client
.
pendingResponses
.
Load
(
SequenceType
(
p
.
Header
.
ID
))
if
!
ok
{
return
perrors
.
Errorf
(
"client.GetPendingResponse(%v) = nil"
,
p
.
Header
.
ID
)
if
p
.
Header
.
Type
&
hessian
.
PackageRequest
!=
0x00
{
// size of this array must be '7'
// https://github.com/apache/dubbo-go-hessian2/blob/master/request.go#L272
p
.
Body
=
make
([]
interface
{},
7
)
}
else
{
pendingRsp
,
ok
:=
client
.
pendingResponses
.
Load
(
SequenceType
(
p
.
Header
.
ID
))
if
!
ok
{
return
perrors
.
Errorf
(
"client.GetPendingResponse(%v) = nil"
,
p
.
Header
.
ID
)
}
p
.
Body
=
&
hessian
.
Response
{
RspObj
:
pendingRsp
.
(
*
PendingResponse
)
.
response
.
reply
}
}
p
.
Body
=
&
hessian
.
Response
{
RspObj
:
pendingRsp
.
(
*
PendingResponse
)
.
response
.
reply
}
}
// read body
...
...
This diff is collapsed.
Click to expand it.
protocol/dubbo/listener.go
+
15
−
9
View file @
01f84dc5
...
...
@@ -85,11 +85,17 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) {
}
if
p
.
Header
.
Type
&
hessian
.
PackageHeartbeat
!=
0x00
{
logger
.
Debugf
(
"get rpc heartbeat response{header: %#v, body: %#v}"
,
p
.
Header
,
p
.
Body
)
if
p
.
Err
!=
nil
{
logger
.
Errorf
(
"rpc heartbeat response{error: %#v}"
,
p
.
Err
)
if
p
.
Header
.
Type
&
hessian
.
PackageResponse
!=
0x00
{
logger
.
Debugf
(
"get rpc heartbeat response{header: %#v, body: %#v}"
,
p
.
Header
,
p
.
Body
)
if
p
.
Err
!=
nil
{
logger
.
Errorf
(
"rpc heartbeat response{error: %#v}"
,
p
.
Err
)
}
h
.
conn
.
pool
.
rpcClient
.
removePendingResponse
(
SequenceType
(
p
.
Header
.
ID
))
}
else
{
logger
.
Debugf
(
"get rpc heartbeat request{header: %#v, service: %#v, body: %#v}"
,
p
.
Header
,
p
.
Service
,
p
.
Body
)
p
.
Header
.
ResponseStatus
=
hessian
.
Response_OK
reply
(
session
,
p
,
hessian
.
PackageHeartbeat
)
}
h
.
conn
.
pool
.
rpcClient
.
removePendingResponse
(
SequenceType
(
p
.
Header
.
ID
))
return
}
logger
.
Debugf
(
"get rpc response{header: %#v, body: %#v}"
,
p
.
Header
,
p
.
Body
)
...
...
@@ -199,7 +205,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
// heartbeat
if
p
.
Header
.
Type
&
hessian
.
PackageHeartbeat
!=
0x00
{
logger
.
Debugf
(
"get rpc heartbeat request{header: %#v, service: %#v, body: %#v}"
,
p
.
Header
,
p
.
Service
,
p
.
Body
)
h
.
reply
(
session
,
p
,
hessian
.
PackageHeartbeat
)
reply
(
session
,
p
,
hessian
.
PackageHeartbeat
)
return
}
...
...
@@ -226,7 +232,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
if
!
twoway
{
return
}
h
.
reply
(
session
,
p
,
hessian
.
PackageResponse
)
reply
(
session
,
p
,
hessian
.
PackageResponse
)
}
}()
...
...
@@ -241,7 +247,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
logger
.
Errorf
(
err
.
Error
())
p
.
Header
.
ResponseStatus
=
hessian
.
Response_OK
p
.
Body
=
err
h
.
reply
(
session
,
p
,
hessian
.
PackageResponse
)
reply
(
session
,
p
,
hessian
.
PackageResponse
)
return
}
invoker
:=
exporter
.
(
protocol
.
Exporter
)
.
GetInvoker
()
...
...
@@ -266,7 +272,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
if
!
twoway
{
return
}
h
.
reply
(
session
,
p
,
hessian
.
PackageResponse
)
reply
(
session
,
p
,
hessian
.
PackageResponse
)
}
func
(
h
*
RpcServerHandler
)
OnCron
(
session
getty
.
Session
)
{
...
...
@@ -294,7 +300,7 @@ func (h *RpcServerHandler) OnCron(session getty.Session) {
}
}
func
(
h
*
RpcServerHandler
)
reply
(
session
getty
.
Session
,
req
*
DubboPackage
,
tp
hessian
.
PackageType
)
{
func
reply
(
session
getty
.
Session
,
req
*
DubboPackage
,
tp
hessian
.
PackageType
)
{
resp
:=
&
DubboPackage
{
Header
:
hessian
.
DubboHeader
{
SerialID
:
req
.
Header
.
SerialID
,
...
...
This diff is collapsed.
Click to expand it.
protocol/dubbo/readwriter.go
+
4
−
2
View file @
01f84dc5
...
...
@@ -62,8 +62,10 @@ func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface
return
nil
,
0
,
perrors
.
WithStack
(
err
)
}
pkg
.
Err
=
pkg
.
Body
.
(
*
hessian
.
Response
)
.
Exception
pkg
.
Body
=
NewResponse
(
pkg
.
Body
.
(
*
hessian
.
Response
)
.
RspObj
,
pkg
.
Body
.
(
*
hessian
.
Response
)
.
Attachments
)
if
pkg
.
Header
.
Type
&
hessian
.
PackageRequest
==
0x00
{
pkg
.
Err
=
pkg
.
Body
.
(
*
hessian
.
Response
)
.
Exception
pkg
.
Body
=
NewResponse
(
pkg
.
Body
.
(
*
hessian
.
Response
)
.
RspObj
,
pkg
.
Body
.
(
*
hessian
.
Response
)
.
Attachments
)
}
return
pkg
,
hessian
.
HEADER_LENGTH
+
pkg
.
Header
.
BodyLen
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment