Skip to content

Commit

Permalink
Fix #1552 - Migrate jobs to infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Dec 6, 2022
1 parent eddd6db commit 464e2f9
Show file tree
Hide file tree
Showing 91 changed files with 147 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.0" />
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.7.5" />
<PackageReference Include="Microsoft.Azure.Devices" Version="1.38.2" />
<PackageReference Include="Microsoft.Azure.Devices.Provisioning.Service" Version="1.18.2" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Shared.Models.v10;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using AzureIoTHub.Portal.Domain.Entities;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using Models.v10;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using AzureIoTHub.Portal.Models.v10;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Collections.Generic;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Threading.Tasks;
using Shared.Models.v1._0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Threading.Tasks;
using Models.v10.LoRaWAN;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Services
namespace AzureIoTHub.Portal.Application.Services
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Models.v10.LoRaWAN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
<PackageReference Include="prometheus-net" Version="7.0.0" />
<PackageReference Include="Quartz" Version="3.5.0" />
<PackageReference Include="Quartz.Extensions.DependencyInjection" Version="3.5.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.23" />
<PackageReference Include="EntityFrameworkCore.Exceptions.PostgreSQL" Version="6.0.3" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Extensions
namespace AzureIoTHub.Portal.Infrastructure.Extensions
{
using AzureIoTHub.Portal.Domain;
using Quartz;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Shared.Constants;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Exceptions;
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Application.Services;
using Microsoft.Extensions.Logging;
using Quartz;
using Shared.Models.v1._0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Shared.Constants;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Exceptions;
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Application.Services;
using Microsoft.Extensions.Logging;
using Quartz;
using Shared.Models.v1._0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Shared.Constants;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) CGI France. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace AzureIoTHub.Portal.Server.Jobs
namespace AzureIoTHub.Portal.Infrastructure.Jobs
{
using System.Threading.Tasks;
using AzureIoTHub.Portal.Domain.Exceptions;
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Application.Services;
using Microsoft.Extensions.Logging;
using Quartz;
using Shared.Models.v1._0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,36 @@ namespace AzureIoTHub.Portal.Infrastructure.Startup
{
using System.Net;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using AzureIoTHub.Portal.Application.Managers;
using AzureIoTHub.Portal.Application.Mappers;
using AzureIoTHub.Portal.Application.Providers;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Application.Wrappers;
using AzureIoTHub.Portal.Domain;
using AzureIoTHub.Portal.Domain.Options;
using AzureIoTHub.Portal.Domain.Repositories;
using AzureIoTHub.Portal.Infrastructure.Extensions;
using AzureIoTHub.Portal.Infrastructure.Jobs;
using AzureIoTHub.Portal.Infrastructure.Managers;
using AzureIoTHub.Portal.Infrastructure.Mappers;
using AzureIoTHub.Portal.Infrastructure.Providers;
using AzureIoTHub.Portal.Infrastructure.Repositories;
using AzureIoTHub.Portal.Infrastructure.Services;
using AzureIoTHub.Portal.Infrastructure.ServicesHealthCheck;
using AzureIoTHub.Portal.Infrastructure.Wrappers;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Models.v10.LoRaWAN;
using EntityFramework.Exceptions.PostgreSQL;
using Microsoft.Azure.Devices.Provisioning.Service;
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;
using Polly.Extensions.Http;
using AzureIoTHub.Portal.Domain.Repositories;
using AzureIoTHub.Portal.Infrastructure.Repositories;
using AzureIoTHub.Portal.Application.Mappers;
using AzureIoTHub.Portal.Infrastructure.Mappers;
using AzureIoTHub.Portal.Models.v10.LoRaWAN;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Application.Managers;
using AzureIoTHub.Portal.Infrastructure.Managers;
using Azure.Storage.Blobs.Models;
using Microsoft.Extensions.Configuration;
using Quartz;

public static class IServiceCollectionExtension
{
Expand All @@ -44,7 +47,8 @@ public static IServiceCollection AddInfrastructureLayer(this IServiceCollection
.ConfigureDeviceRegstryDependencies(configuration)
.ConfigureServices()
.ConfigureMappers()
.ConfigureHealthCheck();
.ConfigureHealthCheck()
.ConfigureMetricsJobs(configuration);
}

private static IServiceCollection AddLoRaWanSupport(this IServiceCollection services, ConfigHandler configuration)
Expand Down Expand Up @@ -181,5 +185,15 @@ private static IServiceCollection ConfigureImageBlobStorage(this IServiceCollect
opts.BaseUri = container.Uri;
});
}

private static IServiceCollection ConfigureMetricsJobs(this IServiceCollection services, ConfigHandler configuration)
{
return services.AddQuartz(q =>
{
q.AddMetricsService<DeviceMetricExporterJob, DeviceMetricLoaderJob>(configuration);
q.AddMetricsService<EdgeDeviceMetricExporterJob, EdgeDeviceMetricLoaderJob>(configuration);
q.AddMetricsService<ConcentratorMetricExporterJob, ConcentratorMetricLoaderJob>(configuration);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AzureIoTHub.Portal.Server.Controllers.v10
using System.Collections.Generic;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Application.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
{
using System.Collections.Generic;
using System.Threading.Tasks;
using Services;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Shared.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Server.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Domain.Entities;
using AzureIoTHub.Portal.Domain.Exceptions;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Server.Services;
using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using System.Collections.Generic;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Models.v10;
using Services;
using AzureIoTHub.Portal.Application.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace AzureIoTHub.Portal.Server.Controllers.V10
{
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Models.v10;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Models.v10;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

[Authorize]
[ApiController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
{
using System.Collections.Generic;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Shared.Models.v10;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Services;

[Authorize]
[ApiController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Shared.Models.v10;
using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.Logging;
using Models.v10;
using Services;
using Shared.Models;

public abstract class DevicesControllerBase<TDto> : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace AzureIoTHub.Portal.Server.Controllers.V10
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AzureIoTHub.Portal.Application.Services;
using AzureIoTHub.Portal.Domain.Exceptions;
using AzureIoTHub.Portal.Models.v10;
using AzureIoTHub.Portal.Server.Services;
using AzureIoTHub.Portal.Shared.Models.v10;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
Expand Down
Loading

0 comments on commit 464e2f9

Please sign in to comment.