Skip to content

Commit

Permalink
Merge pull request #38 from dynamicweb/mss/20500
Browse files Browse the repository at this point in the history
Added retry when endpoint is not ready for use with a sleep of 5 seco…
  • Loading branch information
MatthiasSort authored Aug 27, 2024
2 parents ef85f30 + 6aac990 commit 8ee1bf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.6.3</Version>
<Version>10.6.4</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>OData Provider</Title>
<Description>The Odata Provider lets you fetch and map data from or to any OData endpoint.</Description>
Expand Down
11 changes: 10 additions & 1 deletion src/ODataSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ private IEnumerable<Dictionary<string, object>> ExtractStream(Stream responseStr
yield return null;
}

private bool HandleRequest(string url, string loggerInfo, IDictionary<string, string> headers)
private bool HandleRequest(string url, string loggerInfo, IDictionary<string, string> headers, int retryCounter = 0)
{
if (CheckIfEndpointIsReadyForUse(url))
{
Expand Down Expand Up @@ -596,6 +596,15 @@ private bool HandleRequest(string url, string loggerInfo, IDictionary<string, st
else
{
_logger?.Info($"Endpoint: '{_endpoint.Name}' is not ready for use on URL: '{url}'");
if (retryCounter < 2)
{
retryCounter++;
_logger?.Info($"Will wait and retry again in 5 seconds.");
Thread.Sleep(5000);
_logger?.Info($"This is retry {retryCounter} out of 2");
HandleRequest(url, loggerInfo, headers, retryCounter);
}

return false;
}
}
Expand Down

0 comments on commit 8ee1bf9

Please sign in to comment.