(enableRPCCompression bool)
| 157 | } |
| 158 | |
| 159 | func (s *Session) OpenCluster(enableRPCCompression bool) error { |
| 160 | if s.config.FetchSize <= 0 { |
| 161 | s.config.FetchSize = DefaultFetchSize |
| 162 | } |
| 163 | if s.config.TimeZone == "" { |
| 164 | s.config.TimeZone = DefaultTimeZone |
| 165 | } |
| 166 | |
| 167 | if s.config.ConnectRetryMax <= 0 { |
| 168 | s.config.ConnectRetryMax = DefaultConnectRetryMax |
| 169 | } |
| 170 | |
| 171 | var err error |
| 172 | |
| 173 | s.protocolFactory = getProtocolFactory(enableRPCCompression) |
| 174 | iprot := s.protocolFactory.GetProtocol(s.trans) |
| 175 | oprot := s.protocolFactory.GetProtocol(s.trans) |
| 176 | s.client = rpc.NewIClientRPCServiceClient(thrift.NewTStandardClient(iprot, oprot)) |
| 177 | req := rpc.TSOpenSessionReq{ |
| 178 | ClientProtocol: rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3, ZoneId: s.config.TimeZone, Username: s.config.UserName, |
| 179 | Password: &s.config.Password, |
| 180 | } |
| 181 | req.Configuration = make(map[string]string) |
| 182 | req.Configuration["sql_dialect"] = s.config.sqlDialect |
| 183 | if s.config.Version == "" { |
| 184 | req.Configuration["version"] = string(DEFAULT_VERSION) |
| 185 | } else { |
| 186 | req.Configuration["version"] = string(s.config.Version) |
| 187 | } |
| 188 | if s.config.Database != "" { |
| 189 | req.Configuration["db"] = s.config.Database |
| 190 | } |
| 191 | |
| 192 | resp, err := s.client.OpenSession(context.Background(), &req) |
| 193 | if err != nil { |
| 194 | return err |
| 195 | } |
| 196 | if timeFactor, err := getTimeFactor(resp); err != nil { |
| 197 | return err |
| 198 | } else { |
| 199 | s.timeFactor = timeFactor |
| 200 | } |
| 201 | s.sessionId = resp.GetSessionId() |
| 202 | s.requestStatementId, err = s.client.RequestStatementId(context.Background(), s.sessionId) |
| 203 | return err |
| 204 | } |
| 205 | |
| 206 | func getProtocolFactory(enableRPCCompression bool) thrift.TProtocolFactory { |
| 207 | if enableRPCCompression { |
no test coverage detected