diff --git a/client/protocol.go b/client/protocol.go index 9781e8b..d2cda1d 100644 --- a/client/protocol.go +++ b/client/protocol.go @@ -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 @@ -58,7 +58,7 @@ const ( LZ4 TSCompressionType = 7 ) -//TSStatusCode +// TSStatusCode const ( SuccessStatus int32 = 200 IncompatibleVersion int32 = 201 diff --git a/client/rpcdataset.go b/client/rpcdataset.go index 631afaa..a9a4483 100644 --- a/client/rpcdataset.go +++ b/client/rpcdataset.go @@ -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)] } diff --git a/client/rpcdataset_test.go b/client/rpcdataset_test.go index 43cd0ba..53070f4 100644 --- a/client/rpcdataset_test.go +++ b/client/rpcdataset_test.go @@ -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 { diff --git a/client/session.go b/client/session.go index 8bd08be..e45605a 100644 --- a/client/session.go +++ b/client/session.go @@ -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 { @@ -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 @@ -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 {