feat(core): WorkloadCacheService - логика
This commit is contained in:
@@ -5,8 +5,8 @@ using PARR.API.Contracts.V1.Responses.Base;
|
|||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Services.Interfaces;
|
using PARR.API.Services.Interfaces;
|
||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.Core.Services.Task.Interfaces;
|
using PARR.Core.Services.TaskServices.Interfaces;
|
||||||
using PARR.Core.Services.Task.Providers;
|
using PARR.Core.Services.TaskServices.Providers;
|
||||||
using PARR.Domain.Common.Roles;
|
using PARR.Domain.Common.Roles;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using PARR.Core.Common.Implementations;
|
using PARR.Core.Common.Implementations;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Services.Task.Handlers;
|
using PARR.Core.Services.TaskServices.Handlers;
|
||||||
using PARR.Core.Services.Task.Handlers.Factory;
|
using PARR.Core.Services.TaskServices.Handlers.Factory;
|
||||||
using PARR.Core.Services.Task.Implementations;
|
using PARR.Core.Services.TaskServices.Implementations;
|
||||||
using PARR.Core.Services.Task.Interfaces;
|
using PARR.Core.Services.TaskServices.Interfaces;
|
||||||
using PARR.Core.Services.Task.Providers;
|
using PARR.Core.Services.TaskServices.Providers;
|
||||||
using PARR.Core.Services.Task.ReconciliationHosted;
|
using PARR.Core.Services.TaskServices.ReconciliationHosted;
|
||||||
using PARR.Core.Services.Workload.Implementations;
|
using PARR.Core.Services.Workload.Implementations;
|
||||||
using PARR.Core.Services.Workload.Interfaces;
|
using PARR.Core.Services.Workload.Interfaces;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
@@ -67,6 +67,7 @@ namespace PARR.Core
|
|||||||
|
|
||||||
|
|
||||||
//services.AddScoped<IUserService, UserService>();
|
//services.AddScoped<IUserService, UserService>();
|
||||||
|
//services.AddTransient<IShortcodesService, ShortcodesService>();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
|||||||
using PARR.Domain.Entities.TaskEntities;
|
using PARR.Domain.Entities.TaskEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Handlers
|
namespace PARR.Core.Services.TaskServices.Handlers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Базовый класс для всех обработчиков задач.
|
/// Базовый класс для всех обработчиков задач.
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using PARR.Domain.Enums;
|
using PARR.Core.Services.TaskServices.Handlers;
|
||||||
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Handlers.Factory
|
namespace PARR.Core.Services.TaskServices.Handlers.Factory
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Фабрика обработчиков
|
/// Фабрика обработчиков
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Handlers.Factory
|
namespace PARR.Core.Services.TaskServices.Handlers.Factory
|
||||||
{
|
{
|
||||||
public class TaskHandlerFactory : ITaskHandlerFactory
|
public class TaskHandlerFactory : ITaskHandlerFactory
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PARR.Core.Services.Task.Handlers
|
namespace PARR.Core.Services.TaskServices.Handlers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Результат выполнения задачи обработчиком.
|
/// Результат выполнения задачи обработчиком.
|
||||||
@@ -3,7 +3,7 @@ using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
|||||||
using PARR.Domain.Entities.TaskEntities;
|
using PARR.Domain.Entities.TaskEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Handlers
|
namespace PARR.Core.Services.TaskServices.Handlers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработчик задачаи формирования отчета по загруженности (формирование КЭШ).
|
/// Обработчик задачаи формирования отчета по загруженности (формирование КЭШ).
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
||||||
using PARR.Core.Services.Task.Interfaces;
|
using PARR.Core.Services.TaskServices.Interfaces;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Entities.Base.History;
|
using PARR.Domain.Entities.Base.History;
|
||||||
using PARR.Domain.Entities.TaskEntities;
|
using PARR.Domain.Entities.TaskEntities;
|
||||||
@@ -11,7 +11,7 @@ using PARR.Domain.Settings;
|
|||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Implementations
|
namespace PARR.Core.Services.TaskServices.Implementations
|
||||||
{
|
{
|
||||||
internal class TaskManagementService : ITaskManagementService
|
internal class TaskManagementService : ITaskManagementService
|
||||||
{
|
{
|
||||||
@@ -2,15 +2,15 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
using PARR.Core.Repositories.Interfaces.TaskRepositories;
|
||||||
using PARR.Core.Services.Task.Interfaces;
|
using PARR.Core.Services.TaskServices.Interfaces;
|
||||||
using PARR.Core.Services.Task.Models;
|
using PARR.Core.Services.TaskServices.Models;
|
||||||
using PARR.Core.Services.Task.Providers;
|
using PARR.Core.Services.TaskServices.Providers;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Entities.TaskEntities;
|
using PARR.Domain.Entities.TaskEntities;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Implementations
|
namespace PARR.Core.Services.TaskServices.Implementations
|
||||||
{
|
{
|
||||||
internal class TaskReconciliationService : ITaskReconciliationService
|
internal class TaskReconciliationService : ITaskReconciliationService
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Interfaces
|
namespace PARR.Core.Services.TaskServices.Interfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Управления задачами (очередями)
|
/// Управления задачами (очередями)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using PARR.Core.Services.Task.Models;
|
using PARR.Core.Services.TaskServices.Models;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Interfaces
|
namespace PARR.Core.Services.TaskServices.Interfaces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис для проверки и исправления зависших задач.
|
/// Сервис для проверки и исправления зависших задач.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PARR.Core.Services.Task.Models
|
namespace PARR.Core.Services.TaskServices.Models
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Отчет о выполнении Reconciliation Job.
|
/// Отчет о выполнении Reconciliation Job.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Providers
|
namespace PARR.Core.Services.TaskServices.Providers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Провайдер настроек очереди для задач Tasks
|
/// Провайдер настроек очереди для задач Tasks
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.Providers
|
namespace PARR.Core.Services.TaskServices.Providers
|
||||||
{
|
{
|
||||||
internal class TaskMqSettingsProvider : ITaskMqSettingsProvider
|
internal class TaskMqSettingsProvider : ITaskMqSettingsProvider
|
||||||
{
|
{
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Services.Task.Interfaces;
|
using PARR.Core.Services.TaskServices.Interfaces;
|
||||||
using PARR.Domain.Settings;
|
using PARR.Domain.Settings;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Task.ReconciliationHosted
|
namespace PARR.Core.Services.TaskServices.ReconciliationHosted
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Фоновая задача для периодического запуска Reconciliation Job.
|
/// Фоновая задача для периодического запуска Reconciliation Job.
|
||||||
@@ -33,7 +33,7 @@ namespace PARR.Core.Services.Task.ReconciliationHosted
|
|||||||
this.intervalService = intervalService;
|
this.intervalService = intervalService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async System.Threading.Tasks.Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
await intervalService.IntervalInitAsync(async () =>
|
await intervalService.IntervalInitAsync(async () =>
|
||||||
{
|
{
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
using PARR.Core.Common.Interfaces.RabbitServices;
|
using PARR.Core.Common.Interfaces.RabbitServices;
|
||||||
using PARR.Core.Services.Task.Handlers.Factory;
|
using PARR.Core.Services.TaskServices.Handlers.Factory;
|
||||||
using PARR.Core.Services.Workload.Interfaces;
|
using PARR.Core.Services.Workload.Interfaces;
|
||||||
using PARR.Domain.Common.Rabbit.Messages;
|
using PARR.Domain.Common.Rabbit.Messages;
|
||||||
using PARR.Domain.Enums;
|
using PARR.Domain.Enums;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using InfluxDB.Client.Api.Service;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using PARR.Core.Common.Interfaces;
|
using PARR.Core.Common.Interfaces;
|
||||||
|
using PARR.Core.Repositories.Interfaces;
|
||||||
|
|
||||||
namespace PARR.Core.Services.Workload.Implementations
|
namespace PARR.Core.Services.Workload.Implementations
|
||||||
{
|
{
|
||||||
@@ -10,15 +13,18 @@ namespace PARR.Core.Services.Workload.Implementations
|
|||||||
{
|
{
|
||||||
private readonly ILogger<WorkloadCacheService> logger;
|
private readonly ILogger<WorkloadCacheService> logger;
|
||||||
private readonly IRedisCacheService redisCacheService;
|
private readonly IRedisCacheService redisCacheService;
|
||||||
|
private readonly ITemplateRepository templateRepository;
|
||||||
|
|
||||||
public WorkloadCacheService(
|
public WorkloadCacheService(
|
||||||
ILogger<WorkloadCacheService> logger,
|
ILogger<WorkloadCacheService> logger,
|
||||||
IRedisCacheService redisCacheService
|
IRedisCacheService redisCacheService,
|
||||||
|
ITemplateRepository templateRepository
|
||||||
//IShortcodeService
|
//IShortcodeService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.redisCacheService = redisCacheService;
|
this.redisCacheService = redisCacheService;
|
||||||
|
this.templateRepository = templateRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -27,11 +33,18 @@ namespace PARR.Core.Services.Workload.Implementations
|
|||||||
/// КЭШ рабочих групп и зон ответственности
|
/// КЭШ рабочих групп и зон ответственности
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async System.Threading.Tasks.Task CreateTemplateCacheAsync()
|
public async Task CreateTemplateCacheAsync()
|
||||||
{
|
{
|
||||||
await DeleteTemplateCacheAsync();
|
await DeleteTemplateCacheAsync();
|
||||||
|
await DeleteWorkloadCacheAsync();
|
||||||
|
|
||||||
|
//1. Получить из БД все шаблоны (тяжелый запрос, тянет вообще все данные, 8 сек)
|
||||||
|
var templates = await templateRepository.Get()
|
||||||
|
.AsNoTracking()
|
||||||
|
.Include(t=>t.Job)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
//1. Получить из БД все шаблоны - НЕТ РЕПЫ
|
|
||||||
//2. Получить по каждому шаблону ЗО и РГ
|
//2. Получить по каждому шаблону ЗО и РГ
|
||||||
//3. Сохранить в Redis
|
//3. Сохранить в Redis
|
||||||
|
|
||||||
@@ -42,7 +55,16 @@ namespace PARR.Core.Services.Workload.Implementations
|
|||||||
/// Удалить КЭШ шаблонов.
|
/// Удалить КЭШ шаблонов.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async System.Threading.Tasks.Task DeleteTemplateCacheAsync()
|
public async Task DeleteTemplateCacheAsync()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удалить КЭШ отчетов
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task DeleteWorkloadCacheAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user