Skip to content

Commit e07c3f8

Browse files
authored
Use millisecond as the unit of timeout (#8)
* fix unit * update go mod name * fix build * Revert "fix build" This reverts commit 16ceeb3. * Revert "update go mod name" This reverts commit 20c4266. * refactor
1 parent bffa4a1 commit e07c3f8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Data Source Name expected is of the following format:
3131
databricks://:[your token]@[Workspace hostname][Endpoint HTTP Path]
3232
```
3333

34-
You can set HTTP Timeout value by appending a `timeout` query parameter and you can set max rows to retrieve by setting the `maxRows` query parameter:
34+
You can set HTTP Timeout value by appending a `timeout` query parameter (in milliseconds) and you can set max rows to retrieve by setting the `maxRows` query parameter:
3535

3636
```
3737
databricks://:[your token]@[Workspace hostname][Endpoint HTTP Path]?timeout=1000&maxRows=1000

connection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dbsql
33
import (
44
"context"
55
"database/sql/driver"
6+
"fmt"
67
"log"
78
"time"
89

@@ -91,7 +92,7 @@ func (c *Conn) OpenSession(ctx context.Context) (*hive.Session, error) {
9192
session, err := c.client.OpenSession(ctx)
9293
if err != nil {
9394
c.log.Printf("failed to open session: %v", err)
94-
return nil, driver.ErrBadConn
95+
return nil, fmt.Errorf("%v: %v", driver.ErrBadConn, err)
9596
}
9697
c.session = session
9798
}

driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ func connect(opts *Options) (*Conn, error) {
138138
var err error
139139
var transport thrift.TTransport
140140
logger := log.New(opts.LogOut, "databricks: ", log.LstdFlags)
141-
141+
timeout := time.Duration(opts.Timeout * int(time.Millisecond))
142142
httpClient := &http.Client{
143-
Timeout: time.Duration(opts.Timeout),
143+
Timeout: timeout,
144144
Transport: &http.Transport{
145145
TLSClientConfig: &tls.Config{},
146146
},

0 commit comments

Comments
 (0)