-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impr: BKTCLT-35 go client: custom HTTP client
Add the possibility to attach a custom HTTP client to a new instance of BucketClient. The first intended use is to add a timeout to HTTP requests sent by BucketClient.
- Loading branch information
1 parent
c0be0a4
commit 535c9ce
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
package bucketclient | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
type BucketClient struct { | ||
Endpoint string | ||
Metrics *BucketClientMetrics | ||
Endpoint string | ||
HTTPClient *http.Client | ||
Metrics *BucketClientMetrics | ||
} | ||
|
||
// New creates a new BucketClient instance, with the provided endpoint (e.g. "localhost:9000") | ||
// and the default HTTP client. | ||
func New(bucketdEndpoint string) *BucketClient { | ||
return &BucketClient{ | ||
Endpoint: bucketdEndpoint, | ||
Endpoint: bucketdEndpoint, | ||
HTTPClient: http.DefaultClient, | ||
} | ||
} | ||
|
||
// NewWithHTTPClient creates a new BucketClient instance, with the provided endpoint | ||
// (e.g. "localhost:9000") using the provided http.Client instance. | ||
func NewWithHTTPClient(bucketdEndpoint string, httpClient *http.Client) *BucketClient { | ||
return &BucketClient{ | ||
Endpoint: bucketdEndpoint, | ||
HTTPClient: httpClient, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters