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
4b879147
Commit
4b879147
authored
Nov 06, 2021
by
wei.xuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:remove unused
parent
b2e16fa9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
25 deletions
+14
-25
client.go
client.go
+1
-9
connection.go
connection.go
+10
-11
go.mod
go.mod
+0
-1
go.sum
go.sum
+0
-2
logger.go
logger.go
+1
-0
session.go
session.go
+2
-2
No files found.
client.go
View file @
4b879147
...
@@ -123,9 +123,6 @@ func (c *client) dialTCP() Session {
...
@@ -123,9 +123,6 @@ func (c *client) dialTCP() Session {
)
)
for
{
for
{
if
c
.
IsClosed
()
{
return
nil
}
if
c
.
sslEnabled
{
if
c
.
sslEnabled
{
if
sslConfig
,
buildTlsConfErr
:=
c
.
tlsConfigBuilder
.
BuildTlsConfig
();
buildTlsConfErr
==
nil
&&
sslConfig
!=
nil
{
if
sslConfig
,
buildTlsConfErr
:=
c
.
tlsConfigBuilder
.
BuildTlsConfig
();
buildTlsConfErr
==
nil
&&
sslConfig
!=
nil
{
d
:=
&
net
.
Dialer
{
Timeout
:
connectTimeout
}
d
:=
&
net
.
Dialer
{
Timeout
:
connectTimeout
}
...
@@ -410,11 +407,6 @@ func (c *client) reConnect() {
...
@@ -410,11 +407,6 @@ func (c *client) reConnect() {
interval
=
reconnectInterval
interval
=
reconnectInterval
}
}
for
{
for
{
if
c
.
IsClosed
()
{
log
.
Warnf
(
"client{peer:%s} goroutine exit now."
,
c
.
addr
)
break
}
num
=
c
.
sessionNum
()
num
=
c
.
sessionNum
()
if
max
<=
num
{
if
max
<=
num
{
break
break
...
@@ -425,7 +417,7 @@ func (c *client) reConnect() {
...
@@ -425,7 +417,7 @@ func (c *client) reConnect() {
times
=
maxTimes
times
=
maxTimes
}
}
rinterval
:=
time
.
Duration
(
int64
(
times
)
*
int64
(
interval
))
rinterval
:=
time
.
Duration
(
int64
(
times
)
*
int64
(
interval
))
log
.
Infof
(
"
reConnect %+v
"
,
rinterval
)
log
.
Infof
(
"
==============client reConnect %+v===========
"
,
rinterval
)
<-
gxtime
.
After
(
rinterval
)
<-
gxtime
.
After
(
rinterval
)
}
}
}
}
...
...
connection.go
View file @
4b879147
...
@@ -26,7 +26,6 @@ import (
...
@@ -26,7 +26,6 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/golang/snappy"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
perrors
"github.com/pkg/errors"
perrors
"github.com/pkg/errors"
uatomic
"go.uber.org/atomic"
uatomic
"go.uber.org/atomic"
...
@@ -240,11 +239,11 @@ func (t *gettyTCPConn) SetCompressType(c CompressType) {
...
@@ -240,11 +239,11 @@ func (t *gettyTCPConn) SetCompressType(c CompressType) {
}
}
t
.
writer
=
&
writeFlusher
{
flusher
:
w
}
t
.
writer
=
&
writeFlusher
{
flusher
:
w
}
case
CompressSnappy
:
//
case CompressSnappy:
ioReader
:=
io
.
Reader
(
t
.
conn
)
//
ioReader := io.Reader(t.conn)
t
.
reader
=
snappy
.
NewReader
(
ioReader
)
//
t.reader = snappy.NewReader(ioReader)
ioWriter
:=
io
.
Writer
(
t
.
conn
)
//
ioWriter := io.Writer(t.conn)
t
.
writer
=
snappy
.
NewBufferedWriter
(
ioWriter
)
//
t.writer = snappy.NewBufferedWriter(ioWriter)
default
:
default
:
panic
(
fmt
.
Sprintf
(
"illegal comparess type %d"
,
c
))
panic
(
fmt
.
Sprintf
(
"illegal comparess type %d"
,
c
))
...
@@ -337,11 +336,11 @@ func (t *gettyTCPConn) close(waitSec int) {
...
@@ -337,11 +336,11 @@ func (t *gettyTCPConn) close(waitSec int) {
// }
// }
if
t
.
conn
!=
nil
{
if
t
.
conn
!=
nil
{
if
writer
,
ok
:=
t
.
writer
.
(
*
snappy
.
Writer
);
ok
{
//
if writer, ok := t.writer.(*snappy.Writer); ok {
if
err
:=
writer
.
Close
();
err
!=
nil
{
//
if err := writer.Close(); err != nil {
log
.
Errorf
(
"snappy.Writer.Close() = error:%+v"
,
err
)
//
log.Errorf("snappy.Writer.Close() = error:%+v", err)
}
//
}
}
//
}
if
conn
,
ok
:=
t
.
conn
.
(
*
net
.
TCPConn
);
ok
{
if
conn
,
ok
:=
t
.
conn
.
(
*
net
.
TCPConn
);
ok
{
_
=
conn
.
SetLinger
(
waitSec
)
_
=
conn
.
SetLinger
(
waitSec
)
_
=
conn
.
Close
()
_
=
conn
.
Close
()
...
...
go.mod
View file @
4b879147
...
@@ -4,7 +4,6 @@ go 1.17
...
@@ -4,7 +4,6 @@ go 1.17
require (
require (
github.com/adamweixuan/gostnops v1.11.20-0.20211029124314-3f0589fceea6
github.com/adamweixuan/gostnops v1.11.20-0.20211029124314-3f0589fceea6
github.com/golang/snappy v0.0.4
github.com/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.4.2
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1
go.uber.org/atomic v1.9.0
go.uber.org/atomic v1.9.0
...
...
go.sum
View file @
4b879147
...
@@ -5,8 +5,6 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx
...
@@ -5,8 +5,6 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
...
...
logger.go
View file @
4b879147
...
@@ -100,6 +100,7 @@ func SetLoggerCallerDisable() error {
...
@@ -100,6 +100,7 @@ func SetLoggerCallerDisable() error {
var
err
error
var
err
error
zapLoggerConfig
.
Development
=
false
zapLoggerConfig
.
Development
=
false
zapLoggerConfig
.
DisableCaller
=
true
zapLoggerConfig
.
DisableCaller
=
true
zapLoggerConfig
.
DisableStacktrace
=
true
zapLogger
,
err
=
zapLoggerConfig
.
Build
()
zapLogger
,
err
=
zapLoggerConfig
.
Build
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
session.go
View file @
4b879147
...
@@ -381,7 +381,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
...
@@ -381,7 +381,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
pkgBytes
,
err
:=
s
.
writer
.
Write
(
s
,
pkg
)
pkgBytes
,
err
:=
s
.
writer
.
Write
(
s
,
pkg
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warnf
(
"%s, [session.WritePkg] session.writer.Write(@pkg:%#v) = error:%+v"
,
s
.
Stat
(),
pkg
,
err
)
log
.
Warnf
(
"%s, [session.WritePkg] session.writer.Write(@pkg:%#v) = error:%+v"
,
s
.
Stat
(),
pkg
,
err
)
return
len
(
pkgBytes
),
0
,
perrors
.
WithStack
(
err
)
return
len
(
pkgBytes
),
0
,
err
}
}
var
udpCtxPtr
*
UDPContext
var
udpCtxPtr
*
UDPContext
if
udpCtx
,
ok
:=
pkg
.
(
UDPContext
);
ok
{
if
udpCtx
,
ok
:=
pkg
.
(
UDPContext
);
ok
{
...
@@ -402,7 +402,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
...
@@ -402,7 +402,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
succssCount
,
err
=
s
.
Connection
.
send
(
pkg
)
succssCount
,
err
=
s
.
Connection
.
send
(
pkg
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warnf
(
"%s, [session.WritePkg] @s.Connection.Write(pkg:%#v) = err:%+v"
,
s
.
Stat
(),
pkg
,
err
)
log
.
Warnf
(
"%s, [session.WritePkg] @s.Connection.Write(pkg:%#v) = err:%+v"
,
s
.
Stat
(),
pkg
,
err
)
return
len
(
pkgBytes
),
succssCount
,
perrors
.
WithStack
(
err
)
return
len
(
pkgBytes
),
succssCount
,
err
}
}
return
len
(
pkgBytes
),
succssCount
,
nil
return
len
(
pkgBytes
),
succssCount
,
nil
}
}
...
...
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