Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
eb3db7d1
Unverified
Commit
eb3db7d1
authored
Aug 01, 2018
by
Xin.Zh
Committed by
GitHub
Aug 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from hudangwei/feature/rpc
LGTM
parents
43189243
5c8fc02f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
client.go
rpc/client.go
+13
-5
session.go
session.go
+4
-0
No files found.
rpc/client.go
View file @
eb3db7d1
...
...
@@ -21,9 +21,10 @@ import (
)
var
(
errInvalidAddress
=
jerrors
.
New
(
"remote address invalid or empty"
)
errSessionNotExist
=
jerrors
.
New
(
"session not exist"
)
errClientClosed
=
jerrors
.
New
(
"client closed"
)
errInvalidAddress
=
jerrors
.
New
(
"remote address invalid or empty"
)
errSessionNotExist
=
jerrors
.
New
(
"session not exist"
)
errClientClosed
=
jerrors
.
New
(
"client closed"
)
errClientReadTimeout
=
jerrors
.
New
(
"client read timeout"
)
)
func
init
()
{
...
...
@@ -141,9 +142,16 @@ func (c *Client) Call(addr, protocol, service, method string, args interface{},
if
err
:=
c
.
transfer
(
session
,
b
,
resp
);
err
!=
nil
{
return
jerrors
.
Trace
(
err
)
}
<-
resp
.
done
return
jerrors
.
Trace
(
resp
.
err
)
var
err
error
select
{
case
<-
getty
.
GetTimeWheel
()
.
After
(
c
.
conf
.
GettySessionParam
.
tcpReadTimeout
)
:
err
=
errClientReadTimeout
c
.
RemovePendingResponse
(
resp
.
seq
)
case
<-
resp
.
done
:
err
=
resp
.
err
}
return
jerrors
.
Trace
(
err
)
}
func
(
c
*
Client
)
Close
()
{
...
...
session.go
View file @
eb3db7d1
...
...
@@ -49,6 +49,10 @@ var (
wheel
=
gxtime
.
NewWheel
(
gxtime
.
TimeMillisecondDuration
(
100
),
1200
)
// wheel longest span is 2 minute
)
func
GetTimeWheel
()
*
gxtime
.
Wheel
{
return
wheel
}
// getty base session
type
session
struct
{
name
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment