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
4d9bb90a
Commit
4d9bb90a
authored
4 years ago
by
fangyincheng
Browse files
Options
Downloads
Patches
Plain Diff
modify default heartbeat time & add timeoutTimes in client
parent
71201233
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
remoting/getty/config.go
+2
-2
2 additions, 2 deletions
remoting/getty/config.go
remoting/getty/listener.go
+15
-8
15 additions, 8 deletions
remoting/getty/listener.go
with
17 additions
and
10 deletions
remoting/getty/config.go
+
2
−
2
View file @
4d9bb90a
...
...
@@ -197,7 +197,7 @@ func (c *ClientConfig) CheckValidity() error {
}
if
len
(
c
.
HeartbeatTimeout
)
==
0
{
c
.
heartbeatTimeout
=
5
*
time
.
Second
c
.
heartbeatTimeout
=
60
*
time
.
Second
}
else
if
c
.
heartbeatTimeout
,
err
=
time
.
ParseDuration
(
c
.
HeartbeatTimeout
);
err
!=
nil
{
return
perrors
.
WithMessagef
(
err
,
"time.ParseDuration(HeartbeatTimeout{%#v})"
,
c
.
HeartbeatTimeout
)
}
...
...
@@ -214,7 +214,7 @@ func (c *ServerConfig) CheckValidity() error {
var
err
error
if
len
(
c
.
HeartbeatPeriod
)
==
0
{
c
.
heartbeatPeriod
=
15
*
time
.
Second
c
.
heartbeatPeriod
=
60
*
time
.
Second
}
else
if
c
.
heartbeatPeriod
,
err
=
time
.
ParseDuration
(
c
.
HeartbeatPeriod
);
err
!=
nil
{
return
perrors
.
WithMessagef
(
err
,
"time.ParseDuration(HeartbeatPeroid{%#v})"
,
c
.
HeartbeatPeriod
)
}
...
...
This diff is collapsed.
Click to expand it.
remoting/getty/listener.go
+
15
−
8
View file @
4d9bb90a
...
...
@@ -66,7 +66,8 @@ func (s *rpcSession) GetReqNum() int32 {
// nolint
type
RpcClientHandler
struct
{
conn
*
gettyRPCClient
conn
*
gettyRPCClient
timeoutTimes
int
}
// nolint
...
...
@@ -115,7 +116,7 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) {
logger
.
Errorf
(
"illegal request but not heartbeart. {%#v}"
,
req
)
return
}
h
.
timeoutTimes
=
0
p
:=
result
.
Result
.
(
*
remoting
.
Response
)
// get heartbeart
if
p
.
Event
{
...
...
@@ -126,10 +127,6 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) {
h
.
conn
.
pool
.
rpcClient
.
responseHandler
.
Handler
(
p
)
return
}
if
result
.
IsRequest
{
logger
.
Errorf
(
"illegal package for it is response type. {%#v}"
,
pkg
)
return
}
logger
.
Debugf
(
"get rpc response{%#v}"
,
p
)
...
...
@@ -156,8 +153,14 @@ func (h *RpcClientHandler) OnCron(session getty.Session) {
heartbeatCallBack
:=
func
(
err
error
)
{
if
err
!=
nil
{
logger
.
Warnf
(
"failed to send heartbeat, error{%v}"
,
err
)
h
.
conn
.
removeSession
(
session
)
if
h
.
timeoutTimes
>=
3
{
h
.
conn
.
removeSession
(
session
)
return
}
h
.
timeoutTimes
++
return
}
h
.
timeoutTimes
=
0
}
if
err
:=
h
.
conn
.
pool
.
rpcClient
.
heartbeat
(
session
,
h
.
conn
.
pool
.
rpcClient
.
conf
.
heartbeatTimeout
,
heartbeatCallBack
);
err
!=
nil
{
...
...
@@ -243,10 +246,14 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
logger
.
Debugf
(
"get rpc heartbeat response{%#v}"
,
res
)
if
res
.
Error
!=
nil
{
logger
.
Errorf
(
"rpc heartbeat response{error: %#v}"
,
res
.
Error
)
h
.
rwlock
.
Lock
()
delete
(
h
.
sessionMap
,
session
)
h
.
rwlock
.
Unlock
()
session
.
Close
()
}
return
}
logger
.
Errorf
(
"illegal package
for it is response type
. {%#v}"
,
pkg
)
logger
.
Errorf
(
"illegal package
but not heartbeart
. {%#v}"
,
pkg
)
return
}
req
:=
decodeResult
.
Result
.
(
*
remoting
.
Request
)
...
...
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