pgterminate/notifier/notifier.go

24 lines
618 B
Go
Raw Normal View History

2018-06-10 08:44:53 +02:00
package notifier
import (
"github.com/jouir/pgterminate/base"
)
// Notifier generic interface for implementing a notifier
type Notifier interface {
Run()
Reload()
}
// NewNotifier looks into Config to create a File or Console notifier and pass it
// the session channel for consuming sessions structs sent by terminator
func NewNotifier(ctx *base.Context) Notifier {
if ctx.Config.LogFile != "" {
return NewFile(ctx.Config.LogFile, ctx.Sessions)
}
2018-06-24 16:10:26 +02:00
if ctx.Config.SyslogFacility != "" {
return NewSyslog(ctx.Config.SyslogFacility, ctx.Config.SyslogIdent, ctx.Sessions)
}
2018-06-10 08:44:53 +02:00
return NewConsole(ctx.Sessions)
}