Skip to content

Commit

Permalink
Fixing an issue where only setting timeout value in QoS would result …
Browse files Browse the repository at this point in the history
…in a exception getting thrown. Issue ThreeMammals#908
  • Loading branch information
DanHarltey authored and raman-m committed Aug 2, 2023
1 parent 433dfca commit 673b5e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/Ocelot.Provider.Polly/PollyCircuitBreakingDelegatingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
try
{
return await Policy
.WrapAsync(_qoSProvider.CircuitBreaker.Policies)
.ExecuteAsync(() => base.SendAsync(request, cancellationToken));
IAsyncPolicy policy;

if (_qoSProvider.CircuitBreaker.Policies.Length == 1)
{
policy = _qoSProvider.CircuitBreaker.Policies[0];
}
else
{
policy = Policy.WrapAsync(_qoSProvider.CircuitBreaker.Policies);
}

return await policy.ExecuteAsync(() => base.SendAsync(request, cancellationToken));
}
catch (BrokenCircuitException ex)
{
Expand Down
1 change: 0 additions & 1 deletion test/Ocelot.AcceptanceTests/PollyQoSTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void should_timeout()
QoSOptions = new FileQoSOptions
{
TimeoutValue = 10,
ExceptionsAllowedBeforeBreaking = 10,
},
},
},
Expand Down

0 comments on commit 673b5e1

Please sign in to comment.