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

* feat(cache): remove the references of old cache * feat(cache): add orgID in query range modules pt1 * feat(cache): add orgID in query range modules pt2 * feat(cache): add orgID in query range modules pt3 * feat(cache): preload metrics for all orgs * feat(cache): fix ruler * feat(cache): fix go build * feat(cache): add orgID to rule * feat(cache): fix tests * feat(cache): address review comments * feat(cache): use correct errors * feat(cache): fix tests * feat(cache): add the cache test package
41 lines
954 B
Go
41 lines
954 B
Go
package rules
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
ruletypes "github.com/SigNoz/signoz/pkg/types/ruletypes"
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
|
)
|
|
|
|
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 valuer.UUID) Task {
|
|
if taskType == TaskTypeCh {
|
|
return NewRuleTask(name, file, frequency, rules, opts, notify, maintenanceStore, orgID)
|
|
}
|
|
return NewPromRuleTask(name, file, frequency, rules, opts, notify, maintenanceStore, orgID)
|
|
}
|