Skip to content

Commit 8029fae

Browse files
Updated requested changes
1 parent 84dd852 commit 8029fae

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/LCT.APICommunications.UTest/RetryHttpClientHandlerUTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public async Task ExecuteWithRetryAsync_ShouldCompleteSuccessfully_WhenActionSuc
123123
var action = new Func<Task>(() =>
124124
{
125125
attempts++;
126-
if (attempts < ApiConstant.APIRetryCount)
126+
if (attempts < ApiConstant.APIRetryIntervals.Count)
127127
{
128128
throw new WebException("Temporary error", WebExceptionStatus.Timeout);
129129
}
@@ -134,7 +134,7 @@ public async Task ExecuteWithRetryAsync_ShouldCompleteSuccessfully_WhenActionSuc
134134
await RetryHttpClientHandler.ExecuteWithRetryAsync(action);
135135

136136
// Assert
137-
Assert.AreEqual(ApiConstant.APIRetryCount, attempts, "Action should have been attempted the expected number of times.");
137+
Assert.AreEqual(ApiConstant.APIRetryIntervals.Count, attempts, "Action should have been attempted the expected number of times.");
138138
}
139139

140140
[Test]

src/LCT.APICommunications/ApiConstant.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public static class ApiConstant
7474
public const string InvalidArtifactory = "Invalid artifactory";
7575
public const string PackageNotFound = "Package Not Found";
7676
public const string ArtifactoryRepoName = "ArtifactoryRepoName";
77-
public const string JfrogArtifactoryApiSearchAql = $"/api/search/aql";
78-
public const int APIRetryCount = 3;
77+
public const string JfrogArtifactoryApiSearchAql = $"/api/search/aql";
7978
public static readonly List<int> APIRetryIntervals = [5, 10, 30]; // in seconds
8079
}
8180
}

src/LCT.APICommunications/RetryHttpClientHandler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public RetryHttpClientHandler()
3030
|| (int)r.StatusCode >= 500)
3131
&& r.StatusCode != HttpStatusCode.Unauthorized
3232
&& r.StatusCode != HttpStatusCode.Forbidden)
33-
.WaitAndRetryAsync(ApiConstant.APIRetryCount,
33+
.WaitAndRetryAsync(ApiConstant.APIRetryIntervals.Count,
3434
GetRetryInterval,
3535
onRetry: (outcome, timespan, attempt, context) =>
3636
{
@@ -69,7 +69,7 @@ public static async Task ExecuteWithRetryAsync(Func<Task> action)
6969
{
7070
var retryPolicy = Policy
7171
.Handle<WebException>()
72-
.WaitAndRetryAsync(ApiConstant.APIRetryCount,
72+
.WaitAndRetryAsync(ApiConstant.APIRetryIntervals.Count,
7373
GetRetryInterval,
7474
onRetry: (exception, timespan, attempt, context) =>
7575
{

0 commit comments

Comments
 (0)