func WithRequestTimeout(timeout time.Duration) Option {
	return func(am *Alertmanager) error {
		am.RequestTimeout = timeout
		return nil
	}
}
WithRequestTimeout option can be passed to NewAlertmanager in order to set
a custom timeout for Alertmanager upstream requests
package alertmanager
import (
	"fmt"
	"net/http"
	"sync"
	"time"
	"github.com/cloudflare/unsee/internal/models"
	"github.com/cloudflare/unsee/internal/uri"
	log "github.com/sirupsen/logrus"
)
type Option func(am *Alertmanager) error
var (
	upstreams = map[string]*Alertmanager{}
)
func NewAlertmanager(name, upstreamURI string, opts ...Option) (*Alertmanager, error) {
	am := &Alertmanager{
		URI:            upstreamURI,
		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,
				labelValueErrorsSilences: 0,
			},
		},
	}
	for _, opt := range opts {
		err := opt(am)
		if err != nil {
			return nil, err
		}
	}
	var err error
	am.reader, err = uri.NewReader(am.URI, am.RequestTimeout, am.HTTPTransport)
	if err != nil {
		return am, err
	}
	return am, nil
}
func RegisterAlertmanager(am *Alertmanager) error {
	if _, found := upstreams[am.Name]; found {
		return fmt.Errorf("Alertmanager upstream '%s' already exist", am.Name)
	}
	for _, existingAM := range upstreams {
		if existingAM.URI == am.URI {
			return fmt.Errorf("Alertmanager upstream '%s' already collects from '%s'", existingAM.Name, existingAM.URI)
		}
	}
	upstreams[am.Name] = am
	log.Infof("[%s] Configured Alertmanager source at %s (proxied: %v)", am.Name, am.URI, am.ProxyRequests)
	return nil
}
func GetAlertmanagers() []*Alertmanager {
	ams := []*Alertmanager{}
	for _, am := range upstreams {
		ams = append(ams, am)
	}
	return ams
}
func GetAlertmanagerByName(name string) *Alertmanager {
	am, found := upstreams[name]
	if found {
		return am
	}
	return nil
}
func WithProxy(proxied bool) Option {
	return func(am *Alertmanager) error {
		am.ProxyRequests = proxied
		return nil
	}
}