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
8b0e100a
Commit
8b0e100a
authored
Jun 07, 2019
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imp: delete time wheel
parent
3f195ce4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
26 deletions
+16
-26
change_log.md
change_log.md
+7
-2
client.go
client.go
+6
-12
server.go
server.go
+1
-2
session.go
session.go
+2
-10
No files found.
change_log.md
View file @
8b0e100a
...
...
@@ -14,11 +14,16 @@
## develop history ##
---
-
2019/06/07
> Improvement
*
use time.After instead of wheel.After
*
add remark for tcp reading
-
2018/10/16
> Feature
*
add rpc/micro CallOneway/AsyncCall
*
version: v1.0.3
-
2018/08/19
> Feature
*
use multiple service config in service configuration
...
...
@@ -32,7 +37,7 @@
-
2018/08/13
> Feature
*
Add Micro
-
2018/08/07
> Improvement
*
RPC package format: {2 Bytes Header len + Header + 2 Body len + Body} ---> {Header + Body}
...
...
client.go
View file @
8b0e100a
...
...
@@ -138,8 +138,7 @@ func (c *client) dialTCP() Session {
}
log
.
Infof
(
"net.DialTimeout(addr:%s, timeout:%v) = error:%+v"
,
c
.
addr
,
connectTimeout
,
err
)
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
}
}
...
...
@@ -167,8 +166,7 @@ func (c *client) dialUDP() Session {
}
if
err
!=
nil
{
log
.
Warnf
(
"net.DialTimeout(addr:%s, timeout:%v) = error:%+v"
,
c
.
addr
,
err
)
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
continue
}
...
...
@@ -177,8 +175,7 @@ func (c *client) dialUDP() Session {
if
length
,
err
=
conn
.
Write
(
connectPingPackage
[
:
]);
err
!=
nil
{
conn
.
Close
()
log
.
Warnf
(
"conn.Write(%s) = {length:%d, err:%+v}"
,
string
(
connectPingPackage
),
length
,
err
)
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
continue
}
conn
.
SetReadDeadline
(
time
.
Now
()
.
Add
(
1e9
))
...
...
@@ -189,8 +186,7 @@ func (c *client) dialUDP() Session {
if
err
!=
nil
{
log
.
Infof
(
"conn{%#v}.Read() = {length:%d, err:%+v}"
,
conn
,
length
,
err
)
conn
.
Close
()
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
continue
}
//if err == nil {
...
...
@@ -228,8 +224,7 @@ func (c *client) dialWS() Session {
}
log
.
Infof
(
"websocket.dialer.Dial(addr:%s) = error:%+v"
,
c
.
addr
,
err
)
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
}
}
...
...
@@ -307,8 +302,7 @@ func (c *client) dialWSS() Session {
}
log
.
Infof
(
"websocket.dialer.Dial(addr:%s) = error:%+v"
,
c
.
addr
,
err
)
// time.Sleep(connInterval)
<-
wheel
.
After
(
connInterval
)
time
.
Sleep
(
connInterval
)
}
}
...
...
server.go
View file @
8b0e100a
...
...
@@ -233,8 +233,7 @@ func (s *server) runTcpEventLoop(newSession NewSessionCallback) {
return
}
if
delay
!=
0
{
// time.Sleep(delay)
<-
wheel
.
After
(
delay
)
time
.
Sleep
(
delay
)
}
client
,
err
=
s
.
accept
(
newSession
)
if
err
!=
nil
{
...
...
session.go
View file @
8b0e100a
...
...
@@ -41,14 +41,6 @@ const (
// session
/////////////////////////////////////////
var
(
wheel
=
NewWheel
(
time
.
Millisecond
*
100
,
1200
)
// wheel longest span is 2 minute
)
func
GetTimeWheel
()
*
Wheel
{
return
wheel
}
// getty base session
type
session
struct
{
name
string
...
...
@@ -337,7 +329,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) error {
case
s
.
wQ
<-
pkg
:
break
// for possible gen a new pkg
case
<-
wheel
.
After
(
timeout
)
:
case
<-
time
.
After
(
timeout
)
:
log
.
Warnf
(
"%s, [session.WritePkg] wQ{len:%d, cap:%d}"
,
s
.
Stat
(),
len
(
s
.
wQ
),
cap
(
s
.
wQ
))
return
ErrSessionBlocked
}
...
...
@@ -510,7 +502,7 @@ LOOP:
log
.
Infof
(
"[session.handleLoop] drop writeout package{%#v}"
,
outPkg
)
}
case
<-
wheel
.
After
(
s
.
period
)
:
case
<-
time
.
After
(
s
.
period
)
:
if
flag
{
if
wsFlag
{
err
:=
wsConn
.
writePing
()
...
...
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