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
+17
View File
@@ -93,6 +93,12 @@ var (
// PhantomJs Rendering
ImagesDir string
PhantomDir string
//Notifications
NotificationsEnabled bool
RabbitmqUrl string
NotificationsExchange string
)
func init() {
@@ -219,6 +225,17 @@ func NewConfigContext() {
LogRootPath = Cfg.Section("log").Key("root_path").MustString(path.Join(WorkDir, "/data/log"))
// Notifications
NotificationsEnabled = Cfg.Section("notifications").Key("enabled").MustBool(false)
RabbitmqUrl = Cfg.Section("notifications").Key("rabbitmq_url").MustString("amqp://localhost/")
// validate rabbitmqUrl.
_, err = url.Parse(RabbitmqUrl)
if err != nil {
log.Fatal(4, "Invalid rabbitmq_url(%s): %s", RabbitmqUrl, err)
}
NotificationsExchange = Cfg.Section("notifications").Key("notifications_exchange").MustString("notifications")
readSessionConfig()
}