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
7620b773
Commit
7620b773
authored
4 years ago
by
haohongfan
Browse files
Options
Downloads
Patches
Plain Diff
feat: update the comment of getty/listener
parent
a24034c4
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/listener.go
+15
-15
15 additions, 15 deletions
remoting/getty/listener.go
remoting/getty/readwriter.go
+0
-1
0 additions, 1 deletion
remoting/getty/readwriter.go
with
15 additions
and
16 deletions
remoting/getty/listener.go
+
15
−
15
View file @
7620b773
...
...
@@ -39,7 +39,7 @@ import (
// todo: WritePkg_Timeout will entry *.yml
const
(
// WritePkg_Timeout
...
// WritePkg_Timeout
the timeout of write pkg
WritePkg_Timeout
=
5
*
time
.
Second
)
...
...
@@ -64,35 +64,35 @@ func (s *rpcSession) GetReqNum() int32 {
// RpcClientHandler
// //////////////////////////////////////////
// RpcClientHandler
...
// RpcClientHandler
getty rpc client handler
type
RpcClientHandler
struct
{
conn
*
gettyRPCClient
}
// NewRpcClientHandler
...
// NewRpcClientHandler
new getty rpc client handler
func
NewRpcClientHandler
(
client
*
gettyRPCClient
)
*
RpcClientHandler
{
return
&
RpcClientHandler
{
conn
:
client
}
}
// OnOpen
...
// OnOpen
call the getty client session opened, add the session to getty client session list
func
(
h
*
RpcClientHandler
)
OnOpen
(
session
getty
.
Session
)
error
{
h
.
conn
.
addSession
(
session
)
return
nil
}
// OnError
...
// OnError
the getty client session has errored, so remove the session from the getty client session list
func
(
h
*
RpcClientHandler
)
OnError
(
session
getty
.
Session
,
err
error
)
{
logger
.
Infof
(
"session{%s} got error{%v}, will be closed."
,
session
.
Stat
(),
err
)
h
.
conn
.
removeSession
(
session
)
}
// OnClose
...
// OnClose
close the session, remove it from the getty session list
func
(
h
*
RpcClientHandler
)
OnClose
(
session
getty
.
Session
)
{
logger
.
Infof
(
"session{%s} is closing......"
,
session
.
Stat
())
h
.
conn
.
removeSession
(
session
)
}
// OnMessage
...
// OnMessage
get response from getty server, and update the session to the getty client session list
func
(
h
*
RpcClientHandler
)
OnMessage
(
session
getty
.
Session
,
pkg
interface
{})
{
result
,
ok
:=
pkg
.
(
remoting
.
DecodeResult
)
if
!
ok
{
...
...
@@ -138,7 +138,7 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) {
h
.
conn
.
pool
.
rpcClient
.
responseHandler
.
Handler
(
p
)
}
// OnCron
...
// OnCron
check the session health periodic. if the session's sessionTimeout has reached, just close the session
func
(
h
*
RpcClientHandler
)
OnCron
(
session
getty
.
Session
)
{
rpcSession
,
err
:=
h
.
conn
.
getClientRpcSession
(
session
)
if
err
!=
nil
{
...
...
@@ -169,7 +169,7 @@ type RpcServerHandler struct {
server
*
Server
}
// NewRpcServerHandler
...
// NewRpcServerHandler
new rpc server handler
func
NewRpcServerHandler
(
maxSessionNum
int
,
sessionTimeout
time
.
Duration
,
serverP
*
Server
)
*
RpcServerHandler
{
return
&
RpcServerHandler
{
maxSessionNum
:
maxSessionNum
,
...
...
@@ -179,7 +179,8 @@ func NewRpcServerHandler(maxSessionNum int, sessionTimeout time.Duration, server
}
}
// OnOpen ...
// OnOpen call server session opened, add the session to getty server session list. also onOpen
// will check the max getty server session number
func
(
h
*
RpcServerHandler
)
OnOpen
(
session
getty
.
Session
)
error
{
var
err
error
h
.
rwlock
.
RLock
()
...
...
@@ -198,7 +199,7 @@ func (h *RpcServerHandler) OnOpen(session getty.Session) error {
return
nil
}
// OnError
...
// OnError
the getty server session has errored, so remove the session from the getty server session list
func
(
h
*
RpcServerHandler
)
OnError
(
session
getty
.
Session
,
err
error
)
{
logger
.
Infof
(
"session{%s} got error{%v}, will be closed."
,
session
.
Stat
(),
err
)
h
.
rwlock
.
Lock
()
...
...
@@ -206,7 +207,7 @@ func (h *RpcServerHandler) OnError(session getty.Session, err error) {
h
.
rwlock
.
Unlock
()
}
// OnClose
...
// OnClose
close the session, remove it from the getty server list
func
(
h
*
RpcServerHandler
)
OnClose
(
session
getty
.
Session
)
{
logger
.
Infof
(
"session{%s} is closing......"
,
session
.
Stat
())
h
.
rwlock
.
Lock
()
...
...
@@ -214,7 +215,7 @@ func (h *RpcServerHandler) OnClose(session getty.Session) {
h
.
rwlock
.
Unlock
()
}
// OnMessage
...
// OnMessage
get request from getty client, update the session reqNum and reply response to client
func
(
h
*
RpcServerHandler
)
OnMessage
(
session
getty
.
Session
,
pkg
interface
{})
{
h
.
rwlock
.
Lock
()
if
_
,
ok
:=
h
.
sessionMap
[
session
];
ok
{
...
...
@@ -285,7 +286,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) {
reply
(
session
,
resp
,
hessian
.
PackageResponse
)
}
// OnCron
...
// OnCron
check the session health periodic. if the session's sessionTimeout has reached, just close the session
func
(
h
*
RpcServerHandler
)
OnCron
(
session
getty
.
Session
)
{
var
(
flag
bool
...
...
@@ -312,7 +313,6 @@ func (h *RpcServerHandler) OnCron(session getty.Session) {
}
func
reply
(
session
getty
.
Session
,
resp
*
remoting
.
Response
,
tp
hessian
.
PackageType
)
{
if
err
:=
session
.
WritePkg
(
resp
,
WritePkg_Timeout
);
err
!=
nil
{
logger
.
Errorf
(
"WritePkg error: %#v, %#v"
,
perrors
.
WithStack
(
err
),
resp
)
}
...
...
This diff is collapsed.
Click to expand it.
remoting/getty/readwriter.go
+
0
−
1
View file @
7620b773
...
...
@@ -104,7 +104,6 @@ func NewRpcServerPackageHandler(server *Server) *RpcServerPackageHandler {
func
(
p
*
RpcServerPackageHandler
)
Read
(
ss
getty
.
Session
,
data
[]
byte
)
(
interface
{},
int
,
error
)
{
req
,
length
,
err
:=
(
p
.
server
.
codec
)
.
Decode
(
data
)
//resp,len, err := (*p.).DecodeResponse(buf)
if
err
!=
nil
{
if
err
==
hessian
.
ErrHeaderNotEnough
||
err
==
hessian
.
ErrBodyNotEnough
{
return
nil
,
0
,
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