-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdoc.go
41 lines (31 loc) · 1.49 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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