Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mechanism to judge if the raised error is worth being alerted to admin #81

Merged
merged 3 commits into from
Jun 2, 2019

Conversation

oklahomer
Copy link
Owner

This addresses #73.
Since this feature involves different features and components -- sarah.Alerter, Bot/Adapter.Run()'s error passing function and this new mechanism -- detailed document should be provided.

runner.go Outdated
log.Infof("Stop supervising bot critical error due to context cancellation: %s.", botType)

default:
if r.alertJudge != nil && r.alertJudge(err) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in its document, Bot/Adapter is encouraged to raise any noteworthy error instead of judging if it can handle the error and keep running by itself. It is the runner's task to make such judgment. This alertJudge mechanism is part of such a feature. The document itself mentioned about this with an example of where to place a rate limiter.
As an extension to such usage, this mechanism may be required to make a judgment such as "send alert to administrators and stop Bot when Bot raises FooReconnectFailureErrors three times within ten seconds." The current implementation with a bool return value cannot satisfy such a requirement. The returning value should be capable of acknowledging if the core should send alert and/or stop Bot.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in b4ae170 lets registered supervisor tell how to react to the failing Bot.

@oklahomer oklahomer merged commit 1648c0b into v2.0.0 Jun 2, 2019
@oklahomer oklahomer deleted the feature/judge-alert-policy branch June 2, 2019 11:53
@oklahomer oklahomer added the v2 https://github.com/oklahomer/go-sarah/issues/68 label Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 https://github.com/oklahomer/go-sarah/issues/68
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant