feat(alerting): Plan 02 — backend (domain, storage, evaluators, dispatch) #140

Merged
claude merged 53 commits from feat/alerting-02-backend into main 2026-04-20 09:03:16 +02:00
Showing only changes of commit 2c82b50ea2 - Show all commits

View File

@@ -2,8 +2,10 @@ package com.cameleer.server.app.alerting.eval;
import com.cameleer.server.core.alerting.AlertInstance;
import com.cameleer.server.core.alerting.AlertRule;
import com.cameleer.server.core.alerting.AlertRuleTarget;
import com.cameleer.server.core.alerting.AlertSeverity;
import com.cameleer.server.core.alerting.AlertState;
import com.cameleer.server.core.alerting.TargetKind;
import java.time.Instant;
import java.util.List;
@@ -98,6 +100,20 @@ public final class AlertStateTransitions {
* title/message are left empty here; the job enriches them via MustacheRenderer after.
*/
static AlertInstance newInstance(AlertRule rule, EvalResult.Firing f, AlertState state, Instant now) {
List<AlertRuleTarget> targets = rule.targets() != null ? rule.targets() : List.of();
List<String> targetUserIds = targets.stream()
.filter(t -> t.kind() == TargetKind.USER)
.map(AlertRuleTarget::targetId)
.toList();
List<UUID> targetGroupIds = targets.stream()
.filter(t -> t.kind() == TargetKind.GROUP)
.map(t -> UUID.fromString(t.targetId()))
.toList();
List<String> targetRoleNames = targets.stream()
.filter(t -> t.kind() == TargetKind.ROLE)
.map(AlertRuleTarget::targetId)
.toList();
return new AlertInstance(
UUID.randomUUID(),
rule.id(),
@@ -116,8 +132,8 @@ public final class AlertStateTransitions {
f.context() != null ? f.context() : Map.of(),
"", // title — rendered by job
"", // message — rendered by job
List.of(),
List.of(),
List.of());
targetUserIds,
targetGroupIds,
targetRoleNames);
}
}