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:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user