Resolve all 46 low-severity architecture review findings

This commit is contained in:
Joseph Doherty
2026-09-09 22:56:36 -04:00
parent fef3e7675f
commit 9ee402bbcd
139 changed files with 2621 additions and 1082 deletions
@@ -19,6 +19,64 @@ public class SitePairChannelProviderDisposalTests
Options.Create(new CommunicationOptions()),
NullLogger<SitePairChannelProvider>.Instance);
[Fact]
public async Task Shutdown_RetainsActiveChannelThenDisposesItAtCompletion()
{
using var provider = Build();
provider.UpdateSite("site-1", "http://localhost:15101", null);
var entered = new TaskCompletionSource<GrpcChannel>(TaskCreationOptions.RunContinuationsAsynchronously);
var release = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
var call = provider.ExecuteAsync("site-1", async (channel, ct) =>
{
entered.SetResult(channel);
await release.Task;
_ = channel.CreateCallInvoker();
return 42;
}, CancellationToken.None);
var channel = await entered.Task;
try
{
provider.Dispose();
Assert.Equal(1, provider.ParkedChannelCount);
_ = channel.CreateCallInvoker();
Assert.Throws<ObjectDisposedException>(() => provider.UpdateSite("site-2", "http://localhost:15102", null));
}
finally { release.TrySetResult(); }
Assert.Equal(42, await call);
Assert.Equal(0, provider.ParkedChannelCount);
Assert.Throws<ObjectDisposedException>(() => channel.CreateCallInvoker());
}
[Fact]
public async Task RetiredChannel_SweepKeepsItAliveUntilActualCallCompletion()
{
using var provider = Build();
provider.UpdateSite("site-1", "http://localhost:15101", null);
var entered = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
var release = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
GrpcChannel? held = null;
var call = provider.ExecuteAsync("site-1", async (channel, ct) =>
{
held = channel;
entered.SetResult();
await release.Task;
return 42;
}, CancellationToken.None);
try
{
await entered.Task;
provider.UpdateSite("site-1", "http://localhost:15102", null);
// Simulates any elapsed grace, including waits longer than five minutes.
provider.SweepGraveyard(force: true);
Assert.Equal(1, provider.ParkedChannelCount);
_ = held!.CreateCallInvoker();
}
finally { release.TrySetResult(); await call; }
provider.SweepGraveyard(force: true);
Assert.Equal(0, provider.ParkedChannelCount);
Assert.Throws<ObjectDisposedException>(() => held!.CreateCallInvoker());
}
[Fact]
public async Task ApplyThenUnavailable_DoesNotReplayAnAmbiguousOperation()
{