已完成考生域第一批只读迁移:
GET /api/candidate/dashboard GET /api/candidate/notices GET /api/candidate/profile GET /api/candidate/exams GET /api/candidate/registrations
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
namespace Eis.Infrastructure.Candidate;
|
||||
|
||||
public sealed record CandidateMigrationOptions(bool NativeReadEnabled)
|
||||
{
|
||||
public static CandidateMigrationOptions FromEnvironment(
|
||||
bool configuredNativeReadEnabled,
|
||||
bool authenticationNativeEnabled,
|
||||
bool sharesLegacySessions)
|
||||
{
|
||||
var enabled = ParseBoolean(
|
||||
Environment.GetEnvironmentVariable("CANDIDATE_NATIVE_ENABLED"),
|
||||
configuredNativeReadEnabled);
|
||||
if (enabled && !authenticationNativeEnabled)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"启用原生考生接口前必须同时设置 AUTH_NATIVE_ENABLED=true,以确保 ASP.NET Core 能识别登录会话");
|
||||
}
|
||||
|
||||
var allowMemoryForIsolatedTesting = ParseBoolean(
|
||||
Environment.GetEnvironmentVariable("CANDIDATE_NATIVE_ALLOW_MEMORY"),
|
||||
fallback: false);
|
||||
if (enabled && !sharesLegacySessions && !allowMemoryForIsolatedTesting)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"考生域尚有接口需要转发给 Node;启用原生考生接口必须配置共享 Redis 会话");
|
||||
}
|
||||
|
||||
return new CandidateMigrationOptions(enabled);
|
||||
}
|
||||
|
||||
private static bool ParseBoolean(string? value, bool fallback) => value?.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"1" or "true" or "yes" or "on" => true,
|
||||
"0" or "false" or "no" or "off" => false,
|
||||
_ => fallback
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user