Skip to content

Commit 614a2ea

Browse files
authored
add ConnectRetryMax for config (#65)
1 parent e7dcc09 commit 614a2ea

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

client/protocol.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type TSEncoding uint8
2626
type TSCompressionType uint8
2727

2828
const (
29-
UNKNOW TSDataType = -1
29+
UNKNOWN TSDataType = -1
3030
BOOLEAN TSDataType = 0
3131
INT32 TSDataType = 1
3232
INT64 TSDataType = 2
@@ -58,7 +58,7 @@ const (
5858
LZ4 TSCompressionType = 7
5959
)
6060

61-
//TSStatusCode
61+
// TSStatusCode
6262
const (
6363
SuccessStatus int32 = 200
6464
IncompatibleVersion int32 = 201

client/rpcdataset.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (s *IoTDBRpcDataSet) getColumnIndex(columnName string) int32 {
7979

8080
func (s *IoTDBRpcDataSet) getColumnType(columnName string) TSDataType {
8181
if s.closed {
82-
return UNKNOW
82+
return UNKNOWN
8383
}
8484
return s.columnTypeDeduplicatedList[s.getColumnIndex(columnName)]
8585
}

client/rpcdataset_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestIoTDBRpcDataSet_getColumnType(t *testing.T) {
7676
args: args{
7777
columnName: "root.ln.device1.tick_count",
7878
},
79-
want: UNKNOW,
79+
want: UNKNOWN,
8080
},
8181
}
8282
for _, tt := range tests {

client/session.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,21 @@ import (
3838
)
3939

4040
const (
41-
DefaultTimeZone = "Asia/Shanghai"
42-
DefaultFetchSize = 1024
41+
DefaultTimeZone = "Asia/Shanghai"
42+
DefaultFetchSize = 1024
43+
DefualtConnectRetryMax = 3
4344
)
4445

4546
var errLength = errors.New("deviceIds, times, measurementsList and valuesList's size should be equal")
4647

4748
type Config struct {
48-
Host string
49-
Port string
50-
UserName string
51-
Password string
52-
FetchSize int32
53-
TimeZone string
49+
Host string
50+
Port string
51+
UserName string
52+
Password string
53+
FetchSize int32
54+
TimeZone string
55+
ConnectRetryMax int
5456
}
5557

5658
type Session struct {
@@ -76,6 +78,10 @@ func (s *Session) Open(enableRPCCompression bool, connectionTimeoutInMs int) err
7678
s.config.TimeZone = DefaultTimeZone
7779
}
7880

81+
if s.config.ConnectRetryMax <= 0 {
82+
s.config.ConnectRetryMax = DefualtConnectRetryMax
83+
}
84+
7985
var protocolFactory thrift.TProtocolFactory
8086
var err error
8187

@@ -1090,7 +1096,7 @@ func (s *Session) reconnect() bool {
10901096
var err error
10911097
var connectedSuccess = false
10921098

1093-
for i := 0; i < 3; i++ {
1099+
for i := 0; i < s.config.ConnectRetryMax; i++ {
10941100
for e := endPointList.Front(); e != nil; e = e.Next() {
10951101
err = s.initClusterConn(e.Value.(endPoint))
10961102
if err == nil {

0 commit comments

Comments
 (0)