Route observed daemon reads through reactive state
This commit is contained in:
parent
df41d11ef1
commit
ee9fa6b114
2 changed files with 16 additions and 31 deletions
|
|
@ -7631,8 +7631,8 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root
|
|||
var observedDaemonState = File.ReadAllText(observedDaemonStatePath);
|
||||
var requiredObservedSymbols = new[]
|
||||
{
|
||||
"state.LatestDaemonFrameAsync()",
|
||||
"state.LatestDaemonSoaViewAsync()"
|
||||
".ReactiveObservedDaemonAsync()",
|
||||
"return observed.Current;"
|
||||
};
|
||||
var missingObservedSymbols = requiredObservedSymbols
|
||||
.Where(symbol => !observedDaemonState.Contains(symbol, StringComparison.Ordinal))
|
||||
|
|
@ -7644,6 +7644,14 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root
|
|||
string.Join(", ", missingObservedSymbols));
|
||||
}
|
||||
|
||||
if (observedDaemonState.Contains("state.LatestDaemonFrameAsync()", StringComparison.Ordinal) ||
|
||||
observedDaemonState.Contains("state.LatestDaemonSoaViewAsync()", StringComparison.Ordinal) ||
|
||||
observedDaemonState.Contains("TryReadLatestSoaViewAsync", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Observed daemon state ReadAsync still performs one-shot daemon reads instead of sampling the managed reactive observed document.");
|
||||
}
|
||||
|
||||
var checkedSources = new Dictionary<string, string>
|
||||
{
|
||||
["DaemonRuntimeDocumentTests.cs"] = File.ReadAllText(daemonRuntimeDocumentTestsPath),
|
||||
|
|
@ -14787,8 +14795,8 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
{
|
||||
"public static async Task<AetheriaRuntimeObservedDaemonState?> ReadAsync(",
|
||||
"AetheriaClientState state",
|
||||
"state.LatestDaemonFrameAsync()",
|
||||
"state.LatestDaemonSoaViewAsync()",
|
||||
".ReactiveObservedDaemonAsync()",
|
||||
"return observed.Current;",
|
||||
"AetheriaRuntimeDaemonSoaViewIndex.Build(soaView)",
|
||||
"public sealed class AetheriaRuntimeReactiveObservedDaemonState",
|
||||
"public static async Task<AetheriaRuntimeReactiveObservedDaemonState> CreateAsync(",
|
||||
|
|
|
|||
|
|
@ -33,33 +33,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
{
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
|
||||
var frame = await state.LatestDaemonFrameAsync().ConfigureAwait(false);
|
||||
if (frame == null)
|
||||
return null;
|
||||
|
||||
var soaView = await TryReadLatestSoaViewAsync(state).ConfigureAwait(false);
|
||||
if (soaView == null ||
|
||||
!string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal))
|
||||
{
|
||||
soaView = null;
|
||||
}
|
||||
|
||||
return new AetheriaRuntimeObservedDaemonState(
|
||||
frame,
|
||||
soaView);
|
||||
}
|
||||
|
||||
private static async Task<AetheriaRuntimeDaemonSoaViewDocument?> TryReadLatestSoaViewAsync(
|
||||
AetheriaClientState state)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await state.LatestDaemonSoaViewAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var observed = await state
|
||||
.ReactiveObservedDaemonAsync()
|
||||
.ConfigureAwait(false);
|
||||
return observed.Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue