Add inital implementation of Notification events.

If notifications are enabled in the config, Adds a eventHandler
accepting Notification{} payloads to the internal Bus.  The
eventHandler then marshals the payload into json and sends it
to a rabbitmq topic exchange using the
Notification.Priority+Noticiation.EventType as the routing key.
eg.  INFO.account.created

Currently, notifications are only being emitted for
INFO.account.created
INFO.account.updated
INFO.user.created
INFO.user.updated
This commit is contained in:
woodsaj
2015-02-03 23:57:42 +08:00
parent 68a6a1bc15
commit a712f1a231
9 changed files with 223 additions and 9 deletions
+8 -1
View File
@@ -19,6 +19,7 @@ import (
"github.com/torkelo/grafana-pro/pkg/services/sqlstore"
"github.com/torkelo/grafana-pro/pkg/setting"
"github.com/torkelo/grafana-pro/pkg/social"
"github.com/torkelo/grafana-pro/pkg/services/notification"
)
var CmdWeb = cli.Command{
@@ -81,11 +82,17 @@ func runWeb(c *cli.Context) {
social.NewOAuthService()
sqlstore.NewEngine()
sqlstore.EnsureAdminUser()
var err error
if setting.NotificationsEnabled {
err = notification.Init(setting.RabbitmqUrl, setting.NotificationsExchange)
if err != nil {
log.Fatal(4, "Failed to connect to notification queue: %v", err)
}
}
m := newMacaron()
api.Register(m)
var err error
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl)
switch setting.Protocol {