2021-01-17 09:04:08 -09:00
|
|
|
package alarm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-01-24 13:32:39 -09:00
|
|
|
"alrm/alarm/email"
|
2021-01-17 09:04:08 -09:00
|
|
|
)
|
|
|
|
|
|
|
|
type Alarm interface {
|
|
|
|
Parse(string) (bool, error)
|
2021-01-23 08:27:03 -09:00
|
|
|
Alarm(string, string, string, error) error
|
2021-01-17 09:04:08 -09:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewAlarm(name string, typename string) (Alarm, error) {
|
|
|
|
switch typename {
|
|
|
|
case "email":
|
2021-01-24 13:32:39 -09:00
|
|
|
return email.NewAlarmEmail(name), nil
|
2021-01-17 09:04:08 -09:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unknown alarm name \"%s\"", name)
|
|
|
|
}
|
|
|
|
}
|