mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-07 16:19:07 +00:00
fix(architecture): abstract job run state access
This commit is contained in:
parent
638eccd46c
commit
df291ea9a6
3 changed files with 19 additions and 10 deletions
|
|
@ -13,6 +13,7 @@ using System.Text;
|
||||||
using SeaHaven.DataServices.DependencyInjection;
|
using SeaHaven.DataServices.DependencyInjection;
|
||||||
using SeaHaven.Services.DependencyInjection;
|
using SeaHaven.Services.DependencyInjection;
|
||||||
using SeaHaven.Services.Implementation;
|
using SeaHaven.Services.Implementation;
|
||||||
|
using SeaHaven.Services.Interfaces;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
ConfigurationManager configuration = builder.Configuration;
|
ConfigurationManager configuration = builder.Configuration;
|
||||||
|
|
@ -83,6 +84,8 @@ builder.Services.Configure<SyncOptions>(
|
||||||
builder.Services.Configure<LegacyEndpointOptions>(
|
builder.Services.Configure<LegacyEndpointOptions>(
|
||||||
builder.Configuration.GetSection(LegacyEndpointOptions.SectionName));
|
builder.Configuration.GetSection(LegacyEndpointOptions.SectionName));
|
||||||
builder.Services.AddSingleton<WorkOrderJobRunStateAccessor>();
|
builder.Services.AddSingleton<WorkOrderJobRunStateAccessor>();
|
||||||
|
builder.Services.AddSingleton<IWorkOrderJobRunStateAccessor>(
|
||||||
|
sp => sp.GetRequiredService<WorkOrderJobRunStateAccessor>());
|
||||||
builder.Services.AddSingleton(sp => sp.GetRequiredService<WorkOrderJobRunStateAccessor>().State);
|
builder.Services.AddSingleton(sp => sp.GetRequiredService<WorkOrderJobRunStateAccessor>().State);
|
||||||
builder.Services.AddScoped<Api.SeaHavenIndustries.Filters.IngestApiKeyFilter>();
|
builder.Services.AddScoped<Api.SeaHavenIndustries.Filters.IngestApiKeyFilter>();
|
||||||
builder.Services.AddHostedService<WorkOrderWeekRolledHostedService>();
|
builder.Services.AddHostedService<WorkOrderWeekRolledHostedService>();
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ namespace SeaHaven.Services.Implementation
|
||||||
public class WorkOrderOpsHealthService : IWorkOrderOpsHealthService
|
public class WorkOrderOpsHealthService : IWorkOrderOpsHealthService
|
||||||
{
|
{
|
||||||
private readonly IWorkOrderOpsHealthDataService _healthData;
|
private readonly IWorkOrderOpsHealthDataService _healthData;
|
||||||
private readonly WorkOrderJobRunStateAccessor _runState;
|
private readonly IWorkOrderJobRunStateAccessor _runState;
|
||||||
private readonly WorkOrderOpsHealthOptions _options;
|
private readonly WorkOrderOpsHealthOptions _options;
|
||||||
|
|
||||||
public WorkOrderOpsHealthService(
|
public WorkOrderOpsHealthService(
|
||||||
IWorkOrderOpsHealthDataService healthData,
|
IWorkOrderOpsHealthDataService healthData,
|
||||||
WorkOrderJobRunStateAccessor runState,
|
IWorkOrderJobRunStateAccessor runState,
|
||||||
IOptions<WorkOrderOpsHealthOptions> options)
|
IOptions<WorkOrderOpsHealthOptions> options)
|
||||||
{
|
{
|
||||||
_healthData = healthData;
|
_healthData = healthData;
|
||||||
|
|
@ -58,16 +58,9 @@ namespace SeaHaven.Services.Implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Shared in-memory job run timestamps (API hosted services + ops health).</summary>
|
/// <summary>Shared in-memory job run timestamps (API hosted services + ops health).</summary>
|
||||||
public class WorkOrderJobRunStateAccessor
|
public class WorkOrderJobRunStateAccessor : IWorkOrderJobRunStateAccessor
|
||||||
{
|
{
|
||||||
public WorkOrderJobRunState State { get; } = new();
|
public WorkOrderJobRunState State { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WorkOrderJobRunState
|
|
||||||
{
|
|
||||||
public DateTime? LastWeekRolledRunUtc { get; set; }
|
|
||||||
public DateTime? LastPastDueCacheRunUtc { get; set; }
|
|
||||||
public string? LastWeekRolledError { get; set; }
|
|
||||||
public string? LastPastDueCacheError { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,19 @@ using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace SeaHaven.Services.Interfaces
|
namespace SeaHaven.Services.Interfaces
|
||||||
{
|
{
|
||||||
|
public interface IWorkOrderJobRunStateAccessor
|
||||||
|
{
|
||||||
|
WorkOrderJobRunState State { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class WorkOrderJobRunState
|
||||||
|
{
|
||||||
|
public DateTime? LastWeekRolledRunUtc { get; set; }
|
||||||
|
public DateTime? LastPastDueCacheRunUtc { get; set; }
|
||||||
|
public string? LastWeekRolledError { get; set; }
|
||||||
|
public string? LastPastDueCacheError { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public interface IFileStoragePort
|
public interface IFileStoragePort
|
||||||
{
|
{
|
||||||
Task<string> SaveFileAsync(IFormFile file);
|
Task<string> SaveFileAsync(IFormFile file);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue