Skip to content

Commit

Permalink
Fix #2942 - Add LoraWan service dependency before adding the http cli…
Browse files Browse the repository at this point in the history
…ent.
  • Loading branch information
kbeaugrand committed Apr 16, 2024
1 parent afdf9f2 commit 3ba5994
Showing 1 changed file with 8 additions and 11 deletions.
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

0 comments on commit 3ba5994

Please sign in to comment.