Skip to content

Alerter

Go Hagiwara edited this page Jul 27, 2019 · 5 revisions

When a bot confronts a critical situation and cannot continue its operation or recover, go-sarah's alerting mechanism sends an alert to the administrator. Zero or more sarah.Alerter implementations can be registered to send alerts to desired destinations.

Anything that implements sarah.Alerter can be an alerter, and can be registered via sarah.RegisterAlerter(). As a reference implementation, an alerter that sends a notification to LINE via LINE Notify is provided. This can be used as below:

config := line.NewConfig()
lineAlerter := line.New(config)
sarah.RegisterAlerter(lineAlerter)

By default, Alerter.Alert is called in a panic-proof manner. When an alerter panics or returns error, sarah.Runner leaves a log and tries to send alert with next available sarah.Alerter. So this is recommended to register two or more sarah.Alerters.