Name catalog store reads as managed state bootstrap
This commit is contained in:
parent
5b7a5b3a8c
commit
a204a4e63b
2 changed files with 66 additions and 27 deletions
|
|
@ -10287,10 +10287,12 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
||||||
"AetheriaRuntimeLoadoutTemplatesDocument",
|
"AetheriaRuntimeLoadoutTemplatesDocument",
|
||||||
"ProjectStarbridgeSummaryAsync",
|
"ProjectStarbridgeSummaryAsync",
|
||||||
"var catalog = await catalogDocument.LatestAsync().ConfigureAwait(false);",
|
"var catalog = await catalogDocument.LatestAsync().ConfigureAwait(false);",
|
||||||
"ReadRuntimeCatalogSnapshot()",
|
"BootstrapCatalogDocument(",
|
||||||
"ReadLoadoutTemplatesDocument()",
|
"CatalogBootstrapSource(",
|
||||||
"ReadPlayerSettingsDocument()",
|
"BootstrapRuntimeCatalogSnapshot()",
|
||||||
"ReadVerseHostSettingsDocument()",
|
"BootstrapLoadoutTemplatesDocument()",
|
||||||
|
"BootstrapPlayerSettingsDocument()",
|
||||||
|
"BootstrapVerseHostSettingsDocument()",
|
||||||
"SubmitDaemonCommandAsync(",
|
"SubmitDaemonCommandAsync(",
|
||||||
"SubmitEveCommandAsync(",
|
"SubmitEveCommandAsync(",
|
||||||
"AetheriaRuntimeVerseRecordKeys.DaemonCommand(command.CommandId)",
|
"AetheriaRuntimeVerseRecordKeys.DaemonCommand(command.CommandId)",
|
||||||
|
|
@ -10402,16 +10404,46 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
||||||
? client.Substring(starbridgeSummaryStart, indexedDocumentStart - starbridgeSummaryStart)
|
? client.Substring(starbridgeSummaryStart, indexedDocumentStart - starbridgeSummaryStart)
|
||||||
: client.Substring(starbridgeSummaryStart);
|
: client.Substring(starbridgeSummaryStart);
|
||||||
if (!starbridgeSummaryBlock.Contains("var catalog = await catalogDocument.LatestAsync().ConfigureAwait(false);", StringComparison.Ordinal) ||
|
if (!starbridgeSummaryBlock.Contains("var catalog = await catalogDocument.LatestAsync().ConfigureAwait(false);", StringComparison.Ordinal) ||
|
||||||
starbridgeSummaryBlock.Contains("ReadRuntimeCatalogSnapshot()", StringComparison.Ordinal))
|
starbridgeSummaryBlock.Contains("BootstrapRuntimeCatalogSnapshot()", StringComparison.Ordinal) ||
|
||||||
|
starbridgeSummaryBlock.Contains("AetheriaRuntimeCatalogStore.OpenReadOnly", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"Starbridge summary projection must use the managed runtime catalog document instead of reopening the catalog store.");
|
"Starbridge summary projection must use the managed runtime catalog document instead of reopening the catalog store.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var requiredClientBootstrapSymbols = new[]
|
||||||
|
{
|
||||||
|
"BootstrapCatalogDocument(",
|
||||||
|
"CatalogBootstrapSource(",
|
||||||
|
"legacy catalog store bootstrap seed for managed Aetheria state",
|
||||||
|
"BootstrapRuntimeCatalogSnapshot()",
|
||||||
|
"BootstrapLoadoutTemplatesDocument()",
|
||||||
|
"BootstrapPlayerSettingsDocument()",
|
||||||
|
"BootstrapVerseHostSettingsDocument()"
|
||||||
|
};
|
||||||
|
var missingClientBootstrapSymbols = requiredClientBootstrapSymbols
|
||||||
|
.Where(symbol => !client.Contains(symbol, StringComparison.Ordinal))
|
||||||
|
.ToArray();
|
||||||
|
if (missingClientBootstrapSymbols.Length > 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"AetheriaRuntimeVerseClient must name catalog/settings file reads as bootstrap seeds for managed documents: " +
|
||||||
|
string.Join(", ", missingClientBootstrapSymbols));
|
||||||
|
}
|
||||||
|
|
||||||
var forbiddenClientCompatibilityStoreBypasses = new[]
|
var forbiddenClientCompatibilityStoreBypasses = new[]
|
||||||
{
|
{
|
||||||
"return Task.FromResult(AetheriaRuntimeCatalogStore.ReadPlayerSettings(StatePath));",
|
"return Task.FromResult(AetheriaRuntimeCatalogStore.ReadPlayerSettings(StatePath));",
|
||||||
"return Task.FromResult(AetheriaRuntimeCatalogStore.ReadVerseHostSettings(StatePath));",
|
"return Task.FromResult(AetheriaRuntimeCatalogStore.ReadVerseHostSettings(StatePath));",
|
||||||
|
"ReadRuntimeCatalogSnapshot()",
|
||||||
|
"ReadLoadoutTemplatesDocument()",
|
||||||
|
"ReadPlayerSettingsDocument()",
|
||||||
|
"ReadVerseHostSettingsDocument()",
|
||||||
|
"var catalogDocument = CatalogDocument(",
|
||||||
|
"var loadoutTemplatesDocument = CatalogDocument(",
|
||||||
|
"CultMeshDocumentHandle<TDocument> CatalogDocument<TDocument>(",
|
||||||
|
"projected Aetheria catalog document",
|
||||||
|
"Aetheria typed catalog state",
|
||||||
"public async Task<AetheriaRuntimeDaemonProviderAdvertisementDocument?> GetProviderAdvertisementAsync()",
|
"public async Task<AetheriaRuntimeDaemonProviderAdvertisementDocument?> GetProviderAdvertisementAsync()",
|
||||||
"public async Task<AetheriaRuntimeDaemonHealthDocument?> GetHealthAsync()",
|
"public async Task<AetheriaRuntimeDaemonHealthDocument?> GetHealthAsync()",
|
||||||
"public async Task<AetheriaRuntimeDaemonCommandBoundaryDocument?> GetCommandBoundaryAsync()",
|
"public async Task<AetheriaRuntimeDaemonCommandBoundaryDocument?> GetCommandBoundaryAsync()",
|
||||||
|
|
|
||||||
|
|
@ -528,16 +528,16 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
var frameChanges = WatchLatestFrames()
|
var frameChanges = WatchLatestFrames()
|
||||||
.Where(change => change.Document != null)
|
.Where(change => change.Document != null)
|
||||||
.Select(change => change.Document!);
|
.Select(change => change.Document!);
|
||||||
var catalogDocument = CatalogDocument(
|
var catalogDocument = BootstrapCatalogDocument(
|
||||||
"aetheria.catalog.runtime",
|
"aetheria.catalog.runtime",
|
||||||
() => Task.FromResult(ReadRuntimeCatalogSnapshot()),
|
() => Task.FromResult(BootstrapRuntimeCatalogSnapshot()),
|
||||||
AetheriaRuntimeCatalogSnapshot.SchemaId,
|
AetheriaRuntimeCatalogSnapshot.SchemaId,
|
||||||
CultMesh.ProjectionSource("catalog:aetheria.runtime"));
|
CatalogBootstrapSource("catalog:aetheria.runtime"));
|
||||||
var loadoutTemplatesDocument = CatalogDocument(
|
var loadoutTemplatesDocument = BootstrapCatalogDocument(
|
||||||
"aetheria.catalog.loadout_templates",
|
"aetheria.catalog.loadout_templates",
|
||||||
() => Task.FromResult(ReadLoadoutTemplatesDocument()),
|
() => Task.FromResult(BootstrapLoadoutTemplatesDocument()),
|
||||||
AetheriaRuntimeLoadoutTemplatesDocument.SchemaId,
|
AetheriaRuntimeLoadoutTemplatesDocument.SchemaId,
|
||||||
CultMesh.ProjectionSource("catalog:aetheria.loadout_templates"));
|
CatalogBootstrapSource("catalog:aetheria.loadout_templates"));
|
||||||
var starbridgeScenarioDocument = Document<AetheriaRuntimeStarbridgeScenarioDocument>(
|
var starbridgeScenarioDocument = Document<AetheriaRuntimeStarbridgeScenarioDocument>(
|
||||||
AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest);
|
AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest);
|
||||||
var starbridgeSessionDocument = Document<AetheriaRuntimeStarbridgeSessionDocument>(
|
var starbridgeSessionDocument = Document<AetheriaRuntimeStarbridgeSessionDocument>(
|
||||||
|
|
@ -566,16 +566,16 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
AetheriaRuntimeVerseRecordKeys.DaemonEditorTuiSurface),
|
AetheriaRuntimeVerseRecordKeys.DaemonEditorTuiSurface),
|
||||||
catalogDocument,
|
catalogDocument,
|
||||||
loadoutTemplatesDocument,
|
loadoutTemplatesDocument,
|
||||||
CatalogDocument(
|
BootstrapCatalogDocument(
|
||||||
"aetheria.settings.player",
|
"aetheria.settings.player",
|
||||||
() => Task.FromResult(ReadPlayerSettingsDocument()),
|
() => Task.FromResult(BootstrapPlayerSettingsDocument()),
|
||||||
AetheriaRuntimePlayerSettingsDocument.SchemaId,
|
AetheriaRuntimePlayerSettingsDocument.SchemaId,
|
||||||
CultMesh.ProjectionSource("catalog:aetheria.player_settings")),
|
CatalogBootstrapSource("catalog:aetheria.player_settings")),
|
||||||
CatalogDocument(
|
BootstrapCatalogDocument(
|
||||||
"aetheria.settings.verse_host",
|
"aetheria.settings.verse_host",
|
||||||
() => Task.FromResult(ReadVerseHostSettingsDocument()),
|
() => Task.FromResult(BootstrapVerseHostSettingsDocument()),
|
||||||
AetheriaRuntimeVerseHostSettingsDocument.SchemaId,
|
AetheriaRuntimeVerseHostSettingsDocument.SchemaId,
|
||||||
CultMesh.ProjectionSource("catalog:aetheria.verse_host_settings")),
|
CatalogBootstrapSource("catalog:aetheria.verse_host_settings")),
|
||||||
ProjectedDocument(
|
ProjectedDocument(
|
||||||
"aetheria.current.zone",
|
"aetheria.current.zone",
|
||||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
|
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
|
||||||
|
|
@ -676,27 +676,27 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria typed projected state"));
|
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria typed projected state"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CultMeshDocumentHandle<TDocument> CatalogDocument<TDocument>(
|
CultMeshDocumentHandle<TDocument> BootstrapCatalogDocument<TDocument>(
|
||||||
string documentId,
|
string documentId,
|
||||||
Func<Task<TDocument>> project,
|
Func<Task<TDocument>> bootstrap,
|
||||||
string schemaId,
|
string schemaId,
|
||||||
params CultMeshProjectionSource[] additionalSources)
|
params CultMeshProjectionSource[] additionalSources)
|
||||||
where TDocument : class
|
where TDocument : class
|
||||||
{
|
{
|
||||||
var sources = (additionalSources ?? Array.Empty<CultMeshProjectionSource>())
|
var sources = (additionalSources ?? Array.Empty<CultMeshProjectionSource>())
|
||||||
.Append(CultMesh.ProjectionSource(documentId, schemaId, "projected Aetheria catalog document"))
|
.Append(CultMesh.ProjectionSource(documentId, schemaId, "managed Aetheria catalog document"))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var verse = CultMesh.Verse("aetheria.local", RuntimeId);
|
var verse = CultMesh.Verse("aetheria.local", RuntimeId);
|
||||||
return CultMesh.Document(
|
return CultMesh.Document(
|
||||||
documentId,
|
documentId,
|
||||||
verse,
|
verse,
|
||||||
async _ => await project().ConfigureAwait(false),
|
async _ => await bootstrap().ConfigureAwait(false),
|
||||||
_ => frameChanges
|
_ => frameChanges
|
||||||
.SelectAwait(async (_, cancellationToken) =>
|
.SelectAwait(async (_, cancellationToken) =>
|
||||||
await project().ConfigureAwait(false)),
|
await bootstrap().ConfigureAwait(false)),
|
||||||
sources: sources,
|
sources: sources,
|
||||||
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria typed catalog state"));
|
routeHint: new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria managed catalog state"));
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<AetheriaRuntimeStationRefitDocument> ProjectStationRefitAsync(
|
async Task<AetheriaRuntimeStationRefitDocument> ProjectStationRefitAsync(
|
||||||
|
|
@ -769,24 +769,31 @@ namespace GameCult.Aetheria.State.Verse
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private AetheriaRuntimeCatalogSnapshot ReadRuntimeCatalogSnapshot()
|
private static CultMeshProjectionSource CatalogBootstrapSource(string sourceId)
|
||||||
|
{
|
||||||
|
return CultMesh.ProjectionSource(
|
||||||
|
sourceId,
|
||||||
|
description: "legacy catalog store bootstrap seed for managed Aetheria state");
|
||||||
|
}
|
||||||
|
|
||||||
|
private AetheriaRuntimeCatalogSnapshot BootstrapRuntimeCatalogSnapshot()
|
||||||
{
|
{
|
||||||
return AetheriaRuntimeCatalogStore.OpenReadOnly(StatePath);
|
return AetheriaRuntimeCatalogStore.OpenReadOnly(StatePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AetheriaRuntimeLoadoutTemplatesDocument ReadLoadoutTemplatesDocument()
|
private AetheriaRuntimeLoadoutTemplatesDocument BootstrapLoadoutTemplatesDocument()
|
||||||
{
|
{
|
||||||
return new AetheriaRuntimeLoadoutTemplatesDocument(
|
return new AetheriaRuntimeLoadoutTemplatesDocument(
|
||||||
AetheriaRuntimeCatalogStore.ReadLoadoutTemplates(StatePath));
|
AetheriaRuntimeCatalogStore.ReadLoadoutTemplates(StatePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AetheriaRuntimePlayerSettingsDocument ReadPlayerSettingsDocument()
|
private AetheriaRuntimePlayerSettingsDocument BootstrapPlayerSettingsDocument()
|
||||||
{
|
{
|
||||||
return AetheriaRuntimePlayerSettingsDocument.FromSnapshot(
|
return AetheriaRuntimePlayerSettingsDocument.FromSnapshot(
|
||||||
AetheriaRuntimeCatalogStore.ReadPlayerSettings(StatePath));
|
AetheriaRuntimeCatalogStore.ReadPlayerSettings(StatePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AetheriaRuntimeVerseHostSettingsDocument ReadVerseHostSettingsDocument()
|
private AetheriaRuntimeVerseHostSettingsDocument BootstrapVerseHostSettingsDocument()
|
||||||
{
|
{
|
||||||
return AetheriaRuntimeVerseHostSettingsDocument.FromSnapshot(
|
return AetheriaRuntimeVerseHostSettingsDocument.FromSnapshot(
|
||||||
AetheriaRuntimeCatalogStore.ReadVerseHostSettings(StatePath));
|
AetheriaRuntimeCatalogStore.ReadVerseHostSettings(StatePath));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue