Request peer snapshot documents by record key
This commit is contained in:
parent
a57fa1113a
commit
bd095a5837
3 changed files with 35 additions and 2 deletions
|
|
@ -1839,7 +1839,6 @@ namespace GameCult.Mesh
|
|||
client.SendCultNet(new CultNetSnapshotRequestMessage
|
||||
{
|
||||
MessageId = messageId,
|
||||
SchemaIds = new[] { descriptor.SchemaId },
|
||||
RecordKeys = new[] { recordKey }
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -288,6 +288,11 @@ var health = await remoteHealth.LatestAsync();
|
|||
var uiHealth = remoteHealth.AsSchemaAlias<DaemonHealthUiDocument>();
|
||||
```
|
||||
|
||||
Snapshot requests are record-key-first so same logical documents can still be
|
||||
read when another runtime generated a different schema id for a compatible
|
||||
schema alias. The decode path prefers exact schema id matches when present and
|
||||
falls back to the requested record key.
|
||||
|
||||
A domain facade can collect handles into one schema-aware catalog:
|
||||
|
||||
```csharp
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using GameCult.Networking;
|
||||
using MessagePack;
|
||||
using NUnit.Framework;
|
||||
|
|
@ -887,9 +888,37 @@ public sealed class CultMeshStreamingTests
|
|||
handle.RouteHint.Kind.Should().Be(CultMeshLocalityKind.Network);
|
||||
handle.Sources.Should().ContainSingle().Which.SourceId.Should().Be(key.Value);
|
||||
requests.Should().ContainSingle();
|
||||
requests[0].SchemaIds.Should().ContainSingle().Which.Should().Be(handle.SchemaId);
|
||||
requests[0].SchemaIds.Should().BeNull();
|
||||
requests[0].RecordKeys.Should().ContainSingle().Which.Should().Be(key.Value);
|
||||
(await catalog.LatestAsync<MeshNoteAliasDocument>()).Text.Should().Be("remote-snapshot");
|
||||
|
||||
var aliasSchemaHandle = CultMesh.DocumentFromPeerSnapshot<MeshNoteDocument>(
|
||||
_ => Task.FromResult(new CultNetSnapshotResponseRawMessage
|
||||
{
|
||||
MessageId = "alias-schema",
|
||||
Documents = new[]
|
||||
{
|
||||
new CultNetRawDocumentRecord
|
||||
{
|
||||
SchemaId = "remote.generated.mesh_note_alias.v99",
|
||||
RecordKey = key.Value,
|
||||
StoredAt = DateTimeOffset.UtcNow.ToString("O"),
|
||||
PayloadEncoding = "messagepack",
|
||||
Payload = CultDocumentMessagePackSerialization.SerializeUntyped(
|
||||
new MeshNoteDocument
|
||||
{
|
||||
Schema = "tests.mesh_note.v1",
|
||||
Text = "record-key-fallback",
|
||||
Revision = 10
|
||||
},
|
||||
typeof(MeshNoteDocument))
|
||||
}
|
||||
}
|
||||
}),
|
||||
key.Value,
|
||||
CultMesh.Verse("starbridge", "unity-pilot"));
|
||||
|
||||
(await aliasSchemaHandle.LatestAsync()).Text.Should().Be("record-key-fallback");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue