Harden API memory and CPU usage across Phases 19–22.
Bound list/PDF payloads, stream MinIO I/O with cancellation, paginate history and FHIR $everything, tighten OCR lifetimes/buffers, and add phase tracking docs.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Azure;
|
||||
using Azure.AI.DocumentIntelligence;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
public class AzureDocumentOcrService : IOcrService
|
||||
{
|
||||
@@ -56,26 +55,24 @@ public class AzureDocumentOcrService : IOcrService
|
||||
private readonly ILogger<AzureDocumentOcrService> _logger;
|
||||
|
||||
public AzureDocumentOcrService(
|
||||
IOptions<OcrOptions> options,
|
||||
DocumentIntelligenceClient client,
|
||||
ILogger<AzureDocumentOcrService> logger)
|
||||
{
|
||||
var opts = options.Value.Azure;
|
||||
_client = new DocumentIntelligenceClient(
|
||||
new Uri(opts.Endpoint),
|
||||
new AzureKeyCredential(opts.ApiKey));
|
||||
_client = client;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<OcrExtractionResult> ExtractAsync(
|
||||
Stream documentStream, string contentType)
|
||||
Stream documentStream, string contentType, CancellationToken ct = default)
|
||||
{
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
var content = BinaryData.FromStream(documentStream);
|
||||
var content = await BinaryData.FromStreamAsync(documentStream, ct);
|
||||
var operation = await _client.AnalyzeDocumentAsync(
|
||||
WaitUntil.Completed,
|
||||
"prebuilt-document",
|
||||
content);
|
||||
content,
|
||||
cancellationToken: ct);
|
||||
|
||||
var result = operation.Value;
|
||||
var fields = new List<OcrExtractedField>();
|
||||
|
||||
Reference in New Issue
Block a user