Base Abstraction
The base abstraction for alerters is very basic, as it only defines two abstract methods that subclasses should implement:post()
takes a string, posts it to the desired chat service, and returnsTrue
if the operation succeeded, elseFalse
.ask()
does the same aspost()
, but after sending the message, it waits until someone approves or rejects the operation from within the chat service (e.g., by sending “approve” / “reject” to the bot as response).ask()
then only returnsTrue
if the operation succeeded and was approved, elseFalse
.
Building your own custom alerter
Creating your own custom alerter can be done in three steps:- Create a class that inherits from the
BaseAlerter
and implement thepost()
andask()
methods.
- If you need to configure your custom alerter, you can also implement a config object.
- Finally, you can bring the implementation and the configuration together in a new flavor object.
- The MyAlerterFlavor class is imported and utilized upon the creation of the custom flavor through the CLI.
-
The MyAlerterConfig class is imported when someone tries to register/update a stack component with the
my_alerter
flavor. Especially, during the registration process of the stack component, the config will be used to validate the values given by the user. AsConfig
object are inherentlypydantic
objects, you can also add your own custom validators here. - The MyAlerter only comes into play when the component is ultimately in use.
MyAlerterFlavor
and the MyAlerterConfig
are implemented in a different module/path than the actual MyAlerter
).