Use global httpclient

This commit is contained in:
Eliise S 2020-01-09 10:12:41 +00:00
parent 496587c3bf
commit 1ee73b1324
3 changed files with 10 additions and 3 deletions

View File

@ -10,6 +10,7 @@ type DBClient struct {
// Init initializes the client
func (c *DBClient) Init(option databricks.DBClientOption) DBClient {
c.Option = option
option.Init()
return *c
}

View File

@ -10,6 +10,7 @@ type DBClient struct {
// Init initializes the client
func (c *DBClient) Init(option databricks.DBClientOption) DBClient {
c.Option = option
option.Init()
return *c
}

View File

@ -18,13 +18,15 @@ type DBClientOption struct {
DefaultHeaders map[string]string
InsecureSkipVerify bool
TimeoutSeconds int
client http.Client
}
func (o *DBClientOption) getHTTPClient() http.Client {
// Init initializes the client
func (o *DBClientOption) Init() {
if o.TimeoutSeconds == 0 {
o.TimeoutSeconds = 10
}
client := http.Client{
o.client = http.Client{
Timeout: time.Duration(time.Duration(o.TimeoutSeconds) * time.Second),
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
@ -32,7 +34,10 @@ func (o *DBClientOption) getHTTPClient() http.Client {
},
},
}
return client
}
func (o *DBClientOption) getHTTPClient() http.Client {
return o.client
}
func (o *DBClientOption) getAuthHeader() map[string]string {