-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Package alertmanager provides a framework for monitoring and alerting within the Curio project. It supports dynamic plugin integration for alert notifications, allowing for flexible and extensible alerting mechanisms. | ||
Implementing a New Plugin: | ||
1. Define a struct that implements the Plugin interface, which includes the SendAlert method for dispatching alerts. | ||
2. Implement the SendAlert method to handle the alert logic specific to your plugin. | ||
3. Provide a constructor function for your plugin to facilitate its configuration and initialization. | ||
4. Register your plugin in the LoadAlertPlugins function, which dynamically loads plugins based on the CurioAlertingConfig. | ||
Plugin Configuration: | ||
Plugins are configured through the config.CurioAlertingConfig struct. Each plugin can have its own configuration section within this struct, enabling or disabling the plugin and setting plugin-specific parameters. | ||
Example: | ||
```go | ||
type MyPlugin struct{} | ||
func (p *MyPlugin) SendAlert(data *plugin.AlertPayload) error { | ||
// Plugin-specific alert sending logic | ||
return nil | ||
} | ||
func NewMyPlugin() *MyPlugin { | ||
return &MyPlugin{} | ||
} | ||
func LoadAlertPlugins(cfg config.CurioAlertingConfig) []plugin.Plugin { | ||
var plugins []plugin.Plugin | ||
if cfg.MyPlugin.Enabled { | ||
plugins = append(plugins, NewMyPlugin()) | ||
} | ||
return plugins | ||
} | ||
``` | ||
This package leverages the CurioAlertingConfig for plugin configuration, | ||
enabling a modular approach to adding or removing alerting capabilities as required. | ||
*/ | ||
package alertmanager |