2020-07-13 05:25:48 +00:00
|
|
|
package bbgo
|
|
|
|
|
2020-07-16 07:36:02 +00:00
|
|
|
type Notifier interface {
|
2020-10-22 02:47:54 +00:00
|
|
|
NotifyTo(channel, format string, args ...interface{}) error
|
|
|
|
Notify(format string, args ...interface{}) error
|
2020-07-16 07:36:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type NullNotifier struct{}
|
|
|
|
|
2020-10-22 02:47:54 +00:00
|
|
|
func (n *NullNotifier) NotifyTo(channel, format string, args ...interface{}) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-21 11:52:55 +00:00
|
|
|
func (n *NullNotifier) Notify(format string, args ...interface{}) error {
|
|
|
|
return nil
|
2020-07-16 07:36:02 +00:00
|
|
|
}
|
2020-10-22 02:54:03 +00:00
|
|
|
|
|
|
|
type Notifiability struct {
|
|
|
|
notifiers []Notifier
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Notifiability) AddNotifier(notifier Notifier) {
|
|
|
|
m.notifiers = append(m.notifiers, notifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Notifiability) Notify(msg string, args ...interface{}) {
|
|
|
|
for _, n := range m.notifiers {
|
|
|
|
n.NotifyTo("", msg, args...)
|
|
|
|
}
|
|
|
|
}
|