forked from xiongyuxing/tiku-backend.net
perf: optimize authorization scoreline and workers
This commit is contained in:
24
Tiku.Application/Auth/IRequestSecurityState.cs
Normal file
24
Tiku.Application/Auth/IRequestSecurityState.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Tiku.Application.Auth;
|
||||
|
||||
public interface IRequestSecurityState
|
||||
{
|
||||
AuthSessionValidationResult? ValidatedSession { get; }
|
||||
|
||||
void SetValidatedSession(AuthSessionValidationResult session);
|
||||
}
|
||||
|
||||
internal sealed class RequestSecurityState : IRequestSecurityState
|
||||
{
|
||||
public AuthSessionValidationResult? ValidatedSession { get; private set; }
|
||||
|
||||
public void SetValidatedSession(AuthSessionValidationResult session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
if (ValidatedSession is not null && ValidatedSession != session)
|
||||
{
|
||||
throw new InvalidOperationException("The request security session was already initialized.");
|
||||
}
|
||||
|
||||
ValidatedSession = session;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Tiku.Application.Security;
|
||||
using Tiku.Application.Auth;
|
||||
|
||||
namespace Tiku.Application;
|
||||
|
||||
@@ -8,6 +9,7 @@ public static class DependencyInjection
|
||||
public static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<ICurrentUser, CurrentUser>();
|
||||
services.AddScoped<IRequestSecurityState, RequestSecurityState>();
|
||||
services.AddScoped<TenantContext>();
|
||||
services.AddScoped<ITenantContext>(provider => provider.GetRequiredService<TenantContext>());
|
||||
services.AddScoped<ITenantContextInitializer>(provider => provider.GetRequiredService<TenantContext>());
|
||||
|
||||
@@ -51,10 +51,17 @@ public sealed record ScorelineRecordPage(
|
||||
int Total,
|
||||
IReadOnlyCollection<ScorelineRecordItem> Items);
|
||||
|
||||
public sealed record ScorelineRecordCursorPage(
|
||||
int PageSize,
|
||||
bool HasMore,
|
||||
string? NextCursor,
|
||||
IReadOnlyCollection<ScorelineRecordItem> Items);
|
||||
|
||||
public interface IScorelineQueryService
|
||||
{
|
||||
Task<CatalogList<ScorelineFieldItem>> GetFieldsAsync(ScorelineFilter filter, CancellationToken cancellationToken = default);
|
||||
Task<ScorelineRecordPage> GetRecordsAsync(ScorelineFilter filter, CancellationToken cancellationToken = default);
|
||||
Task<ScorelineRecordCursorPage> GetRecordsCursorAsync(ScorelineFilter filter, string? cursor, CancellationToken cancellationToken = default);
|
||||
Task<CatalogList<ScorelineRecordItem>> GetTrendAsync(ScorelineFilter filter, CancellationToken cancellationToken = default);
|
||||
Task<CatalogList<int>> GetYearsAsync(ScorelineFilter filter, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Tiku.Application.Security;
|
||||
|
||||
public interface ITenantFeatureCacheInvalidator
|
||||
{
|
||||
Task InvalidateAsync(Guid tenantId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Tiku.Application.Tenancy;
|
||||
|
||||
public interface ITenantPublicCacheInvalidator
|
||||
{
|
||||
Task InvalidateAsync(Guid tenantId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -35,5 +35,5 @@ public interface ITenantDomainLifecycleService
|
||||
|
||||
public interface ITenantRuntimeCacheInvalidator
|
||||
{
|
||||
void Invalidate(Guid tenantId);
|
||||
Task InvalidateAsync(Guid tenantId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user