fix(client-dotnet): size the retry outer budget for all attempts (mxaccessgw#197)

ExecuteSafeUnaryAsync capped the whole retry pipeline at one DefaultCallTimeout
while each attempt carried the same deadline, so a DeadlineExceeded first
attempt consumed the whole budget and no retry ever ran. The outer cap is now
MaxAttempts x DefaultCallTimeout + (MaxAttempts-1) x MaxDelay in both
MxGatewayClient and GalaxyRepositoryClient. Adds a slow-first-attempt test
(fails without the fix) and a budget unit test.
This commit is contained in:
Joseph Doherty
2026-11-09 12:02:46 -05:00
parent 20138b60cc
commit fad1c11e44
5 changed files with 118 additions and 4 deletions
@@ -126,18 +126,29 @@ internal sealed class FakeGatewayTransport(MxGatewayClientOptions options) : IMx
return Task.FromResult(CloseSessionReply);
}
/// <summary>
/// Gets or sets an optional behaviour run (before any queued exception) on each InvokeAsync call;
/// receives the 1-based attempt number and the call options.
/// </summary>
public Func<int, CallOptions, Task>? InvokeBehavior { get; set; }
/// <inheritdoc />
public Task<MxCommandReply> InvokeAsync(
public async Task<MxCommandReply> InvokeAsync(
MxCommandRequest request,
CallOptions callOptions)
{
InvokeCalls.Add((request, callOptions));
if (InvokeBehavior is not null)
{
await InvokeBehavior(InvokeCalls.Count, callOptions).ConfigureAwait(false);
}
if (InvokeExceptions.TryDequeue(out Exception? exception))
{
throw exception;
}
return Task.FromResult(_invokeReplies.Dequeue());
return _invokeReplies.Dequeue();
}
/// <inheritdoc />