Rename Alertmanager.Timeout -> Alertmanager.RequestTimeout

This commit is contained in:
Łukasz Mierzwa
2018-01-08 13:51:38 -08:00
parent c8b7b3bcd0
commit efda91f542
3 changed files with 19 additions and 19 deletions

View File

@@ -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
}

View File

@@ -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
}
}

View File

@@ -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()