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 {
)
for
{
if
c
.
IsClosed
()
{
return
nil
}
if
c
.
sslEnabled
{
if
sslConfig
,
buildTlsConfErr
:=
c
.
tlsConfigBuilder
.
BuildTlsConfig
();
buildTlsConfErr
==
nil
&&
sslConfig
!=
nil
{
d
:=
&
net
.
Dialer
{
Timeout
:
connectTimeout
}
...
...
@@ -410,11 +407,6 @@ func (c *client) reConnect() {
interval
=
reconnectInterval
}
for
{
if
c
.
IsClosed
()
{
log
.
Warnf
(
"client{peer:%s} goroutine exit now."
,
c
.
addr
)
break
}
num
=
c
.
sessionNum
()
if
max
<=
num
{
break
...
...
@@ -425,7 +417,7 @@ func (c *client) reConnect() {
times
=
maxTimes
}
rinterval
:=
time
.
Duration
(
int64
(
times
)
*
int64
(
interval
))
log
.
Infof
(
"
reConnect %+v
"
,
rinterval
)
log
.
Infof
(
"
==============client reConnect %+v===========
"
,
rinterval
)
<-
gxtime
.
After
(
rinterval
)
}
}
...
...
connection.go
View file @
4b879147
...
...
@@ -26,7 +26,6 @@ import (
"sync"
"time"
"github.com/golang/snappy"
"github.com/gorilla/websocket"
perrors
"github.com/pkg/errors"
uatomic
"go.uber.org/atomic"
...
...
@@ -240,11 +239,11 @@ func (t *gettyTCPConn) SetCompressType(c CompressType) {
}
t
.
writer
=
&
writeFlusher
{
flusher
:
w
}
case
CompressSnappy
:
ioReader
:=
io
.
Reader
(
t
.
conn
)
t
.
reader
=
snappy
.
NewReader
(
ioReader
)
ioWriter
:=
io
.
Writer
(
t
.
conn
)
t
.
writer
=
snappy
.
NewBufferedWriter
(
ioWriter
)
//
case CompressSnappy:
//
ioReader := io.Reader(t.conn)
//
t.reader = snappy.NewReader(ioReader)
//
ioWriter := io.Writer(t.conn)
//
t.writer = snappy.NewBufferedWriter(ioWriter)
default
:
panic
(
fmt
.
Sprintf
(
"illegal comparess type %d"
,
c
))
...
...
@@ -337,11 +336,11 @@ func (t *gettyTCPConn) close(waitSec int) {
// }
if
t
.
conn
!=
nil
{
if
writer
,
ok
:=
t
.
writer
.
(
*
snappy
.
Writer
);
ok
{
if
err
:=
writer
.
Close
();
err
!=
nil
{
log
.
Errorf
(
"snappy.Writer.Close() = error:%+v"
,
err
)
}
}
//
if writer, ok := t.writer.(*snappy.Writer); ok {
//
if err := writer.Close(); err != nil {
//
log.Errorf("snappy.Writer.Close() = error:%+v", err)
//
}
//
}
if
conn
,
ok
:=
t
.
conn
.
(
*
net
.
TCPConn
);
ok
{
_
=
conn
.
SetLinger
(
waitSec
)
_
=
conn
.
Close
()
...
...
go.mod
View file @
4b879147
...
...
@@ -4,7 +4,6 @@ go 1.17
require (
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/pkg/errors v0.9.1
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
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/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/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
...
...
logger.go
View file @
4b879147
...
...
@@ -100,6 +100,7 @@ func SetLoggerCallerDisable() error {
var
err
error
zapLoggerConfig
.
Development
=
false
zapLoggerConfig
.
DisableCaller
=
true
zapLoggerConfig
.
DisableStacktrace
=
true
zapLogger
,
err
=
zapLoggerConfig
.
Build
()
if
err
!=
nil
{
return
err
...
...
session.go
View file @
4b879147
...
...
@@ -381,7 +381,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
pkgBytes
,
err
:=
s
.
writer
.
Write
(
s
,
pkg
)
if
err
!=
nil
{
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
if
udpCtx
,
ok
:=
pkg
.
(
UDPContext
);
ok
{
...
...
@@ -402,7 +402,7 @@ func (s *session) WritePkg(pkg interface{}, timeout time.Duration) (int, int, er
succssCount
,
err
=
s
.
Connection
.
send
(
pkg
)
if
err
!=
nil
{
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
}
...
...
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