Documentation
¶
Overview ¶
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.
Index ¶
- Constants
- type AlertAPI
- type AlertTask
- func (a *AlertTask) Adder(taskFunc harmonytask.AddTaskFunc)
- func (a *AlertTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) (*harmonytask.TaskID, error)
- func (a *AlertTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (done bool, err error)
- func (a *AlertTask) TypeDetails() harmonytask.TaskTypeDetails
Constants ¶
const AlertMangerInterval = time.Hour
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertAPI ¶
type AlertAPI interface {
ctladdr.NodeApi
ChainHead(context.Context) (*types.TipSet, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
StateMinerPartitions(context.Context, address.Address, uint64, types.TipSetKey) ([]api.Partition, error)
}
type AlertTask ¶
type AlertTask struct {
// contains filtered or unexported fields
}
func NewAlertTask ¶
func NewAlertTask( api AlertAPI, db *harmonydb.DB, alertingCfg config.CurioAlertingConfig, al *curioalerting.AlertingSystem) *AlertTask
func (*AlertTask) Adder ¶
func (a *AlertTask) Adder(taskFunc harmonytask.AddTaskFunc)
func (*AlertTask) CanAccept ¶
func (a *AlertTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.TaskEngine) (*harmonytask.TaskID, error)
func (*AlertTask) TypeDetails ¶
func (a *AlertTask) TypeDetails() harmonytask.TaskTypeDetails