mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-27 23:11:59 +08:00

* feat(ruler): base setup for rules and planned maintenance tables * feat(ruler): more changes for making ruler org aware * feat(ruler): fix lint * feat(ruler): update the edit planned maintenance function * feat(ruler): local testing edits for planned maintenance * feat(ruler): abstract store and types from rules pkg * feat(ruler): abstract store and types from rules pkg * feat(ruler): abstract out store and add migration * feat(ruler): frontend changes and review comments * feat(ruler): add back compareAndSelectConfig * feat(ruler): changes for alertmanager matchers * feat(ruler): addressed review comments * feat(ruler): remove the cascade operations from rules table * feat(ruler): update the template for alertmanager * feat(ruler): implement the rule history changes * feat(ruler): implement the rule history changes * feat(ruler): implement the rule history changes --------- Co-authored-by: Vibhu Pandey <vibhupandey28@gmail.com>
40 lines
910 B
Go
40 lines
910 B
Go
package rules
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
ruletypes "github.com/SigNoz/signoz/pkg/types/ruletypes"
|
|
)
|
|
|
|
type TaskType string
|
|
|
|
const (
|
|
TaskTypeProm = "promql_ruletask"
|
|
TaskTypeCh = "ch_ruletask"
|
|
)
|
|
|
|
type Task interface {
|
|
Name() string
|
|
|
|
// Key returns the group key
|
|
Key() string
|
|
|
|
Type() TaskType
|
|
CopyState(from Task) error
|
|
Eval(ctx context.Context, ts time.Time)
|
|
Run(ctx context.Context)
|
|
Rules() []Rule
|
|
Stop()
|
|
Pause(b bool)
|
|
}
|
|
|
|
// newTask returns an appropriate group for
|
|
// rule type
|
|
func newTask(taskType TaskType, name, file string, frequency time.Duration, rules []Rule, opts *ManagerOptions, notify NotifyFunc, maintenanceStore ruletypes.MaintenanceStore, orgID string) Task {
|
|
if taskType == TaskTypeCh {
|
|
return NewRuleTask(name, file, frequency, rules, opts, notify, maintenanceStore, orgID)
|
|
}
|
|
return NewPromRuleTask(name, file, frequency, rules, opts, notify, maintenanceStore, orgID)
|
|
}
|