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

Fix #2942 - Add LoraWan service dependency before adding the http client #2943

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ namespace IoTHub.Portal.Infrastructure.Startup
using IoTHub.Portal.Models.v10.LoRaWAN;
using Microsoft.Azure.Devices;
using Microsoft.Azure.Devices.Provisioning.Service;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Polly;
Expand Down Expand Up @@ -62,13 +60,13 @@ private static IServiceCollection AddLoRaWanSupport(this IServiceCollection serv
return services;
}

var transientHttpErrorPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(c => c.StatusCode == HttpStatusCode.NotFound)
.WaitAndRetryAsync(3, _ => TimeSpan.FromMilliseconds(100));
_ = services.AddTransient<ILoRaWanManagementService, LoRaWanManagementService>()
.AddTransient<IDeviceService<LoRaDeviceDetails>, LoRaWanDeviceService>();

_ = services.AddHttpClient("RestClient")
.AddPolicyHandler(transientHttpErrorPolicy);
var transientHttpErrorPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(c => c.StatusCode == HttpStatusCode.NotFound)
.WaitAndRetryAsync(3, _ => TimeSpan.FromMilliseconds(100));

_ = services.AddHttpClient<ILoRaWanManagementService, LoRaWanManagementService>((sp, client) =>
{
Expand Down Expand Up @@ -109,9 +107,8 @@ private static IServiceCollection ConfigureMappers(this IServiceCollection servi

private static IServiceCollection ConfigureServices(this IServiceCollection services)
{
return services.AddTransient<ILoRaWanManagementService, LoRaWanManagementService>()
.AddTransient<IDeviceService<DeviceDetails>, DeviceService>()
.AddTransient<IDeviceService<LoRaDeviceDetails>, LoRaWanDeviceService>();
return services
.AddTransient<IDeviceService<DeviceDetails>, DeviceService>();
}

private static IServiceCollection ConfigureHealthCheck(this IServiceCollection services)
Expand Down
Loading