mirror of
https://github.com/SigNoz/signoz.git
synced 2026-04-27 14:10:30 +01:00
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* chore: remove deprecated v3/v4 support in rules * chore: fix test * chore: fix logs * chore: fix logging * chore: fix ci * chore: address review comments
41 lines
944 B
Go
41 lines
944 B
Go
package rules
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"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)
|
|
}
|