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:
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user