feature: Outbox Relay and Kafka Pipeline

This commit is contained in:
voltsrage
2026-06-16 22:12:46 +08:00
parent de603df151
commit 84d259d10c
18 changed files with 1277 additions and 6 deletions
@@ -116,7 +116,7 @@ public class ObservationService : IObservationService
severity = alert.Severity.ToDbString(),
triggeredAt = alert.TriggeredAt,
partitionKey = encounterId.ToString()
}));
}, encounterId.ToString()));
}
// Step 7 — outbox event for the observation (always; Kafka consumer handles warnings)
@@ -131,7 +131,7 @@ public class ObservationService : IObservationService
source = req.Source.ToDbString(),
recordedAt = req.RecordedAt,
partitionKey = encounterId.ToString()
}));
}, encounterId.ToString()));
// Step 8 — COMMIT
await _db.SaveChangesAsync();
@@ -202,11 +202,12 @@ public class ObservationService : IObservationService
return $"{req.ObservationCode} value {req.Value} {req.Unit} is above critical high of {t.CriticalHigh} {req.Unit}.";
}
private static OutboxEvent BuildOutboxEvent(string topic, object payload) => new()
private static OutboxEvent BuildOutboxEvent(string topic, object payload, string partitionKey) => new()
{
Id = Guid.NewGuid(),
Topic = topic,
Payload = JsonSerializer.Serialize(payload),
PartitionKey = partitionKey,
CreatedAt = DateTimeOffset.UtcNow
};