smon/notification/factory.go

24 lines
491 B
Go
Raw Normal View History

2024-05-05 10:10:04 +02:00
package notification
import (
// External
werr "git.gibonuddevalla.se/go/wrappederror"
// Standard
"log/slog"
)
func ServiceFactory(t string, config []byte, prio int, ackURL string, logger *slog.Logger) (Service, error) {
switch t {
case "NTFY":
ntfy, err := NewNTFY(config, prio, ackURL)
if err != nil {
err = werr.Wrap(err).WithData(config)
return nil, err
}
return ntfy, nil
}
return nil, werr.New("Unknown notification service, '%s'", t).WithCode("002-0000")
}