Fix Kafka retry seek, bound buffers, and cut hot-path CPU/memory waste (Phases 41–44).
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user