Fix Kafka retry seek, bound buffers, and cut hot-path CPU/memory waste (Phases 41–44).
CI / changes (push) Successful in 17s
CI / frontend (push) Skipped
CI / backend (push) Successful in 15m10s

Stop consumers from committing past failed offsets, harden Rabbit/DataLake/gateway backpressure, dispose JsonDocument/MinIO correctly, and batch expensive DB/HTTP paths. Track progress in docs/performance.
This commit is contained in:
2026-11-30 21:32:43 +08:00
parent 1c1065938f
commit 68a2ab3204
54 changed files with 959 additions and 311 deletions
@@ -27,6 +27,37 @@ public class PhiAccessLogService : IPhiAccessLogService
public async Task LogViewAsync(Guid patientId, string resourcePath) =>
await WriteAsync(PhiAccessType.View, patientId, resourcePath);
public async Task LogViewsAsync(IReadOnlyList<Guid> patientIds, string resourcePath)
{
if (patientIds.Count == 0) return;
if (!_currentUser.IsAuthenticated || _currentUser.UserId is null) return;
var now = DateTimeOffset.UtcNow;
var userId = _currentUser.UserId.Value;
var display = _currentUser.DisplayName ?? _currentUser.Username ?? "Unknown";
var ip = _currentUser.IpAddress;
var correlationId = _http.HttpContext?.Items["CorrelationId"]?.ToString();
foreach (var patientId in patientIds)
{
_db.PhiAccessLogs.Add(new PhiAccessLog
{
Id = Guid.NewGuid(),
AccessType = PhiAccessType.View,
PatientId = patientId,
UserId = userId,
UserDisplayName = display,
ResourcePath = resourcePath,
IpAddress = ip,
CorrelationId = correlationId,
AccessedAt = now
});
}
await _db.SaveChangesAsync();
_metrics.PhiAccessLogsTotal.WithLabels(PhiAccessType.View.ToDbString()).Inc(patientIds.Count);
}
public async Task LogCreateAsync(Guid patientId, string resourcePath) =>
await WriteAsync(PhiAccessType.Create, patientId, resourcePath);