Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply retry logic to job/pool/task creation and reuse existing code #199

Merged
merged 3 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/TesApi.Tests/TestServices/TestServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ internal TestServiceProvider(
.AddTransient<ILogger<ConfigurationUtils>>(_ => NullLogger<ConfigurationUtils>.Instance)
.AddTransient<ILogger<PriceApiBatchSkuInformationProvider>>(_ => NullLogger<PriceApiBatchSkuInformationProvider>.Instance)
.AddSingleton<TestRepositoryStorage>()
.AddSingleton<CacheAndRetryHandler>()
.AddSingleton<PriceApiClient>()
.AddSingleton<IBatchPoolFactory, BatchPoolFactory>()
.AddTransient<BatchPool>()
Expand Down Expand Up @@ -145,7 +146,14 @@ internal TInstance GetServiceOrCreateInstance<TInstance>()
=> ActivatorUtilities.GetServiceOrCreateInstance<TInstance>(provider);

private static IConfiguration GetConfiguration(IEnumerable<(string Key, string Value)> configuration)
=> new ConfigurationBuilder().AddInMemoryCollection(configuration?.Select(t => new KeyValuePair<string, string>(t.Key, t.Value)) ?? Enumerable.Empty<KeyValuePair<string, string>>()).Build();
=> new ConfigurationBuilder()
.AddInMemoryCollection(new KeyValuePair<string, string/*?*/>[] // defaults
{
new($"{RetryPolicyOptions.SectionName}:{nameof(RetryPolicyOptions.MaxRetryCount)}", "3"),
new($"{RetryPolicyOptions.SectionName}:{nameof(RetryPolicyOptions.ExponentialBackOffExponent)}", "2")
})
.AddInMemoryCollection(configuration?.Select(t => new KeyValuePair<string, string>(t.Key, t.Value)) ?? Enumerable.Empty<KeyValuePair<string, string>>())
.Build();

private Mock<IAzureProxy> GetAzureProxy(Action<Mock<IAzureProxy>> action)
{
Expand Down
Loading