Skip to content

Commit

Permalink
add ConnectRetryMax for config (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
manlge authored Dec 2, 2022
1 parent e7dcc09 commit 614a2ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions client/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type TSEncoding uint8
type TSCompressionType uint8

const (
UNKNOW TSDataType = -1
UNKNOWN TSDataType = -1
BOOLEAN TSDataType = 0
INT32 TSDataType = 1
INT64 TSDataType = 2
Expand Down Expand Up @@ -58,7 +58,7 @@ const (
LZ4 TSCompressionType = 7
)

//TSStatusCode
// TSStatusCode
const (
SuccessStatus int32 = 200
IncompatibleVersion int32 = 201
Expand Down
2 changes: 1 addition & 1 deletion client/rpcdataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (s *IoTDBRpcDataSet) getColumnIndex(columnName string) int32 {

func (s *IoTDBRpcDataSet) getColumnType(columnName string) TSDataType {
if s.closed {
return UNKNOW
return UNKNOWN
}
return s.columnTypeDeduplicatedList[s.getColumnIndex(columnName)]
}
Expand Down
2 changes: 1 addition & 1 deletion client/rpcdataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestIoTDBRpcDataSet_getColumnType(t *testing.T) {
args: args{
columnName: "root.ln.device1.tick_count",
},
want: UNKNOW,
want: UNKNOWN,
},
}
for _, tt := range tests {
Expand Down
24 changes: 15 additions & 9 deletions client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@ import (
)

const (
DefaultTimeZone = "Asia/Shanghai"
DefaultFetchSize = 1024
DefaultTimeZone = "Asia/Shanghai"
DefaultFetchSize = 1024
DefualtConnectRetryMax = 3
)

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

type Config struct {
Host string
Port string
UserName string
Password string
FetchSize int32
TimeZone string
Host string
Port string
UserName string
Password string
FetchSize int32
TimeZone string
ConnectRetryMax int
}

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

if s.config.ConnectRetryMax <= 0 {
s.config.ConnectRetryMax = DefualtConnectRetryMax
}

var protocolFactory thrift.TProtocolFactory
var err error

Expand Down Expand Up @@ -1090,7 +1096,7 @@ func (s *Session) reconnect() bool {
var err error
var connectedSuccess = false

for i := 0; i < 3; i++ {
for i := 0; i < s.config.ConnectRetryMax; i++ {
for e := endPointList.Front(); e != nil; e = e.Next() {
err = s.initClusterConn(e.Value.(endPoint))
if err == nil {
Expand Down

0 comments on commit 614a2ea

Please sign in to comment.