diff --git a/manager/dispatch.go b/manager/dispatch.go index 2f3c6a15..363952a1 100644 --- a/manager/dispatch.go +++ b/manager/dispatch.go @@ -8,6 +8,8 @@ import ( "github.com/prometheus/common/model" "github.com/prometheus/log" "golang.org/x/net/context" + + "github.com/prometheus/alertmanager/provider" ) const ResolveTimeout = 30 * time.Second @@ -16,7 +18,7 @@ const ResolveTimeout = 30 * time.Second // assigns the correct notifiers to each. type Dispatcher struct { routes Routes - alertProvider AlertProvider + alertProvider provider.Alerts aggrGroups map[model.Fingerprint]*aggrGroup notifiers map[string]Notifier diff --git a/manager/provider.go b/provider/provider.go similarity index 78% rename from manager/provider.go rename to provider/provider.go index f6a7e5e3..762e0746 100644 --- a/manager/provider.go +++ b/provider/provider.go @@ -15,10 +15,12 @@ package manager import ( "github.com/prometheus/common/model" + + "github.com/prometheus/alertmanager/config" ) -// AlertProvider gives access to a set of alerts. -type AlertProvider interface { +// Alerts gives access to a set of alerts. +type Alerts interface { // Iter returns a channel on which all active alerts from the // beginning of time are sent. They are not guaranteed to be in // chronological order. @@ -31,8 +33,8 @@ type AlertProvider interface { Del(model.Fingerprint) error } -// SilenceProvider gives access to silences. -type SilenceProvider interface { +// Silences gives access to silences. +type Silences interface { Silencer // All returns all existing silences. @@ -45,9 +47,13 @@ type SilenceProvider interface { Get(model.Fingerprint) (*Silence, error) } -type ConfigProvider interface { - // Reload initiates a configuration reload. - Reload() error - // Get returns the current configuration. - Get() *Config +// Reloadable is a component that can change its state based +// on a new configuration. +type Reloadable interface { + ApplyConfig(*config.Config) +} + +type Config interface { + // Reload initiates a configuration reload. + Reload(...Reloadable) error }