Skip to content

Commit

Permalink
adds method to set http client to realoder
Browse files Browse the repository at this point in the history
Signed-off-by: someshkoli <[email protected]>
  • Loading branch information
someshkoli committed Nov 7, 2021
1 parent 490b154 commit 8e5f70f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func runSidecar(
return errors.Wrap(err, "Improper http client config")
}

reloader.HTTPClient = *httpClient
reloader.SetHttpClient(*httpClient)

var m = &promMetadata{
promURL: conf.prometheus.url,
Expand Down
9 changes: 7 additions & 2 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import (
type Reloader struct {
logger log.Logger
reloadURL *url.URL
HTTPClient http.Client
httpClient http.Client
cfgFile string
cfgOutputFile string
watchInterval time.Duration
Expand Down Expand Up @@ -414,7 +414,7 @@ func (r *Reloader) triggerReload(ctx context.Context) error {
}
req = req.WithContext(ctx)

resp, err := r.HTTPClient.Do(req)
resp, err := r.httpClient.Do(req)
if err != nil {
return errors.Wrap(err, "reload request failed")
}
Expand All @@ -426,6 +426,11 @@ func (r *Reloader) triggerReload(ctx context.Context) error {
return nil
}

// Sets Http client for reloader
func (r *Reloader) SetHttpClient(client http.Client) {
r.httpClient = client
}

// ReloadURLFromBase returns the standard Prometheus reload URL from its base URL.
func ReloadURLFromBase(u *url.URL) *url.URL {
r := *u
Expand Down

0 comments on commit 8e5f70f

Please sign in to comment.