Deliver portable native Architecture B deployment and final verification

This commit is contained in:
Steffen committed 2026-10-14 16:32:20 +02:00
1 parent f451b55de1
commit 36740d2492
92 files changed
+10939 -926

No files matched your search

@@ -5,30 +5,30 @@ namespace HealthApp.Infrastructure;
// Coordinates mechanics only; it has no health table/query or access-policy knowledge.
public sealed class RequestTransaction(NpgsqlDataSource source) : IAsyncDisposable
{
public NpgsqlConnection? Connection {get;private set;}
public NpgsqlTransaction? Transaction {get;private set;}
public bool Active=>Transaction is not null;
public async Task BeginAsync(bool write,CancellationToken ct)
{
if(Active)return;
Connection=await source.OpenConnectionAsync(ct);
Transaction=await Connection.BeginTransactionAsync(write?IsolationLevel.ReadCommitted:IsolationLevel.RepeatableRead,ct);
}
public async Task EnlistAsync(DbContext context,CancellationToken ct)
{
if(Transaction is null || Connection is null)throw new InvalidOperationException("No request transaction.");
if(context.Database.GetDbConnection()!=Connection)context.Database.SetDbConnection(Connection,false);
await context.Database.UseTransactionAsync(Transaction,ct);
}
public async Task FinishAsync(CancellationToken ct)
{
if(Transaction is null)return;
await Transaction.CommitAsync(ct);await Transaction.DisposeAsync();Transaction=null;
await Connection!.DisposeAsync();Connection=null;
}
public async ValueTask DisposeAsync()
{
if(Transaction is not null){await Transaction.DisposeAsync();Transaction=null;}
if(Connection is not null){await Connection.DisposeAsync();Connection=null;}
}
public NpgsqlConnection? Connection { get; private set; }
public NpgsqlTransaction? Transaction { get; private set; }
public bool Active => Transaction is not null;
public async Task BeginAsync(bool write, CancellationToken ct)
{
if (Active) return;
Connection = await source.OpenConnectionAsync(ct);
Transaction = await Connection.BeginTransactionAsync(write ? IsolationLevel.ReadCommitted : IsolationLevel.RepeatableRead, ct);
}
public async Task EnlistAsync(DbContext context, CancellationToken ct)
{
if (Transaction is null || Connection is null) throw new InvalidOperationException("No request transaction.");
if (context.Database.GetDbConnection() != Connection) context.Database.SetDbConnection(Connection, false);
await context.Database.UseTransactionAsync(Transaction, ct);
}
public async Task FinishAsync(CancellationToken ct)
{
if (Transaction is null) return;
await Transaction.CommitAsync(ct); await Transaction.DisposeAsync(); Transaction = null;
await Connection!.DisposeAsync(); Connection = null;
}
public async ValueTask DisposeAsync()
{
if (Transaction is not null) { await Transaction.DisposeAsync(); Transaction = null; }
if (Connection is not null) { await Connection.DisposeAsync(); Connection = null; }
}
}