refactor(architecture): harden module boundaries
Some checks failed
ci / release-gate (push) Has been cancelled
Some checks failed
ci / release-gate (push) Has been cancelled
This commit is contained in:
@@ -24,10 +24,13 @@ internal static class ApiPresentationExtensions
|
||||
services.AddProblemDetails();
|
||||
services.AddScoped<TenantAdminActorResolver>();
|
||||
services.AddScoped<DirectContentActorResolver>();
|
||||
services.AddScoped<TenantContentCapabilitySet>();
|
||||
services.AddScoped<CommerceAdminActorResolver>();
|
||||
services.AddScoped<CommerceRequestContextResolver>();
|
||||
services.AddScoped<LearningActorResolver>();
|
||||
services.AddScoped<PlatformAdminActorResolver>();
|
||||
services.AddScoped<AuthRequestContextResolver>();
|
||||
services.AddScoped<AuthCapabilitySet>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -1,44 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Tiku.Application.PlatformAdmin;
|
||||
using Tiku.Application.Security;
|
||||
using Tiku.Domain.Platform;
|
||||
using Tiku.Infrastructure.Persistence;
|
||||
|
||||
namespace Tiku.Api.Configuration;
|
||||
|
||||
internal sealed class TenantProvisioningStartupValidator(
|
||||
ITenantExecutionScope tenantExecutionScope,
|
||||
ITenantProvisioningReadinessProbe readinessProbe,
|
||||
IOptions<TenantProvisioningOptions> options,
|
||||
ILogger<TenantProvisioningStartupValidator> logger) : IHostedService
|
||||
{
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var offeringCode = options.Value.DefaultBaseOfferingCode.Trim().ToLowerInvariant();
|
||||
var available = await tenantExecutionScope.ExecuteAsync(
|
||||
new SystemScopeRequest(
|
||||
null,
|
||||
SystemScopeCallerType.Platform,
|
||||
nameof(TenantProvisioningStartupValidator),
|
||||
"Validate the production default tenant offering",
|
||||
Guid.NewGuid().ToString("N"),
|
||||
true),
|
||||
async (services, token) =>
|
||||
{
|
||||
var dbContext = services.GetRequiredService<TikuDbContext>();
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
return await (
|
||||
from offering in dbContext.SaasOfferings.AsNoTracking()
|
||||
join version in dbContext.SaasOfferingVersions.AsNoTracking()
|
||||
on offering.Id equals version.OfferingId
|
||||
where offering.Code == offeringCode &&
|
||||
offering.Type == SaasOfferingType.BasePlan &&
|
||||
offering.Status == SaasOfferingStatus.Active &&
|
||||
version.Status == SaasOfferingVersionStatus.Published &&
|
||||
(version.EffectiveAt == null || version.EffectiveAt <= now)
|
||||
select version.Id).AnyAsync(token);
|
||||
},
|
||||
cancellationToken);
|
||||
var available = await readinessProbe.IsPublishedBaseOfferingAvailableAsync(offeringCode, cancellationToken);
|
||||
|
||||
if (!available)
|
||||
throw new InvalidOperationException(
|
||||
@@ -51,4 +24,4 @@ internal sealed class TenantProvisioningStartupValidator(
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user