Nicer notification manager initialization
This commit is contained in:
parent
49af9dc33c
commit
5f6a48e7e0
2
main.go
2
main.go
@ -100,7 +100,7 @@ func main() { // {{{
|
||||
return
|
||||
}
|
||||
|
||||
err = InitNotificationManager()
|
||||
notificationManager, err = InitNotificationManager()
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).Log()
|
||||
logger.Error("notification", "error", err)
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"smon/notification"
|
||||
|
||||
// Standard
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
@ -19,11 +18,9 @@ type DbNotificationService struct {
|
||||
Prio int
|
||||
}
|
||||
|
||||
func InitNotificationManager() (err error) { // {{{
|
||||
func InitNotificationManager() (nm notification.Manager, err error) { // {{{
|
||||
var dbServices []DbNotificationService
|
||||
var row *sql.Row
|
||||
|
||||
row = service.Db.Conn.QueryRow(`
|
||||
row := service.Db.Conn.QueryRow(`
|
||||
WITH services AS (
|
||||
SELECT
|
||||
id,
|
||||
@ -51,7 +48,7 @@ func InitNotificationManager() (err error) { // {{{
|
||||
return
|
||||
}
|
||||
|
||||
notificationManager = notification.NewManager(logger)
|
||||
nm = notification.NewManager(logger)
|
||||
var service notification.Service
|
||||
for _, dbService := range dbServices {
|
||||
service, err = notification.ServiceFactory(
|
||||
@ -65,16 +62,18 @@ func InitNotificationManager() (err error) { // {{{
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithData(dbService.Service)
|
||||
}
|
||||
notificationManager.AddService(service)
|
||||
nm.AddService(service)
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func AcknowledgeNotification(uuid string) (err error) { // {{{
|
||||
/*
|
||||
_, err = service.Db.Conn.Exec(`UPDATE schedule SET acknowledged=true WHERE schedule_uuid=$1`, uuid)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).WithData(uuid)
|
||||
}
|
||||
*/
|
||||
return
|
||||
} // }}}
|
||||
|
Loading…
Reference in New Issue
Block a user