From efda91f542084cee5ad1392b3f99522a6c4dd766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 8 Jan 2018 13:51:38 -0800 Subject: [PATCH] Rename Alertmanager.Timeout -> Alertmanager.RequestTimeout --- internal/alertmanager/models.go | 12 ++++++------ internal/alertmanager/upstream.go | 18 +++++++++--------- proxy_test.go | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/alertmanager/models.go b/internal/alertmanager/models.go index 809ba0edc..ce5399119 100644 --- a/internal/alertmanager/models.go +++ b/internal/alertmanager/models.go @@ -29,9 +29,9 @@ type alertmanagerMetrics struct { // Alertmanager represents Alertmanager upstream instance type Alertmanager struct { - URI string `json:"uri"` - Timeout time.Duration `json:"timeout"` - Name string `json:"name"` + URI string `json:"uri"` + RequestTimeout time.Duration `json:"timeout"` + Name string `json:"name"` // whenever this instance should be proxied ProxyRequests bool // lock protects data access while updating @@ -56,7 +56,7 @@ func (am *Alertmanager) detectVersion() string { return defaultVersion } ver := alertmanagerVersion{} - err = transport.ReadJSON(url, am.Timeout, &ver) + err = transport.ReadJSON(url, am.RequestTimeout, &ver) if err != nil { log.Errorf("[%s] %s request failed: %s", am.Name, url, err.Error()) return defaultVersion @@ -92,7 +92,7 @@ func (am *Alertmanager) pullSilences(version string) error { } start := time.Now() - silences, err := mapper.GetSilences(am.URI, am.Timeout) + silences, err := mapper.GetSilences(am.URI, am.RequestTimeout) if err != nil { return err } @@ -135,7 +135,7 @@ func (am *Alertmanager) pullAlerts(version string) error { } start := time.Now() - groups, err := mapper.GetAlerts(am.URI, am.Timeout) + groups, err := mapper.GetAlerts(am.URI, am.RequestTimeout) if err != nil { return err } diff --git a/internal/alertmanager/upstream.go b/internal/alertmanager/upstream.go index 7b832c0f1..1c52a4e54 100644 --- a/internal/alertmanager/upstream.go +++ b/internal/alertmanager/upstream.go @@ -30,14 +30,14 @@ func NewAlertmanager(name, uri string, opts ...Option) error { } am := &Alertmanager{ - URI: uri, - Timeout: time.Second * 10, - Name: name, - lock: sync.RWMutex{}, - alertGroups: []models.AlertGroup{}, - silences: map[string]models.Silence{}, - colors: models.LabelsColorMap{}, - autocomplete: []models.Autocomplete{}, + URI: uri, + RequestTimeout: time.Second * 10, + Name: name, + lock: sync.RWMutex{}, + alertGroups: []models.AlertGroup{}, + silences: map[string]models.Silence{}, + colors: models.LabelsColorMap{}, + autocomplete: []models.Autocomplete{}, metrics: alertmanagerMetrics{ errors: map[string]float64{ labelValueErrorsAlerts: 0, @@ -88,6 +88,6 @@ func WithProxy(proxied bool) Option { // a custom timeout for Alertmanager upstream requests func WithRequestTimeout(timeout time.Duration) Option { return func(am *Alertmanager) { - am.Timeout = timeout + am.RequestTimeout = timeout } } diff --git a/proxy_test.go b/proxy_test.go index 30ded1702..47621d63d 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -91,10 +91,10 @@ var proxyTests = []proxyTest{ func TestProxy(t *testing.T) { r := ginTestEngine() setupRouterProxyHandlers(r, &alertmanager.Alertmanager{ - URI: "http://localhost:9093", - Timeout: time.Second * 5, - Name: "dummy", - ProxyRequests: true, + URI: "http://localhost:9093", + RequestTimeout: time.Second * 5, + Name: "dummy", + ProxyRequests: true, }) httpmock.Activate()