diff --git a/packages/cultcache-py/README.md b/packages/cultcache-py/README.md index cd1427d6..b23cbb2e 100644 --- a/packages/cultcache-py/README.md +++ b/packages/cultcache-py/README.md @@ -383,7 +383,13 @@ client.sync_peer_catalog(peers, verse_id="python-interop", roles=["read-replica" client.fanout_peer_catalog(peers, verse_id="python-interop", roles=["read-replica"]) raw_client = CultNetRawClient("127.0.0.1", 3075) -node.database.sync_snapshot(raw_client, schema_ids=[note_doc.catalog_entry().schema_id]) +synced_note = node.database.sync_document(raw_client, note_doc, "note:remote") +synced_stock = CultMesh.sync_document( + node, + raw_client, + station_stock_ui_doc, + "station:starbridge:stock", +) node.database.sync_shard_log(raw_client, shard_id="interop", shard_epoch=1) replicator = CultNetShardReplicator( node.database, diff --git a/packages/cultcache-py/src/cultmesh_py/facade.py b/packages/cultcache-py/src/cultmesh_py/facade.py index a7900a44..42ba8859 100644 --- a/packages/cultcache-py/src/cultmesh_py/facade.py +++ b/packages/cultcache-py/src/cultmesh_py/facade.py @@ -7,6 +7,7 @@ from pathlib import Path from typing import Any from urllib.parse import urlparse +from cultcache_py.documents import DocumentDefinition from cultnet_py import ( CultNetRawClient, CultNetReconnectPolicy, @@ -273,6 +274,24 @@ class CultMesh: def create_simulation_fact_committer(node: CultMeshNode) -> CultMeshSimulationFactCommitter: return CultMeshSimulationFactCommitter(node) + @staticmethod + def sync_document( + node: CultMeshNode, + client: CultNetRawClient, + document: DocumentDefinition[Any], + key: str, + *, + shard_id: str | None = None, + shard_epoch: int | None = None, + ) -> Any: + return node.sync_document( + client, + document, + key, + shard_id=shard_id, + shard_epoch=shard_epoch, + ) + @staticmethod def create_game_session( node: CultMeshNode, diff --git a/packages/cultcache-py/tests/test_cultcache.py b/packages/cultcache-py/tests/test_cultcache.py index c9648f8d..d1c9c568 100644 --- a/packages/cultcache-py/tests/test_cultcache.py +++ b/packages/cultcache-py/tests/test_cultcache.py @@ -2113,17 +2113,28 @@ class CultCacheTests(unittest.TestCase): } synced = node.sync_document(SnapshotClient(), alias, "note:remote") + facade_synced = CultMesh.sync_document(node, SnapshotClient(), alias, "note:remote") self.assertIsInstance(synced, UiNote) self.assertEqual(synced.body, "synced-alias") + self.assertIsInstance(facade_synced, UiNote) + self.assertEqual(facade_synced.body, "synced-alias") self.assertEqual(node.get_required(document, "note:remote").body, "synced-alias") self.assertIsInstance(node.get_required(alias, "note:remote"), UiNote) - self.assertEqual(requests, [{ - "schema_ids": ["mesh.sync_alias_note.v1"], - "record_keys": ["note:remote"], - "shard_id": None, - "shard_epoch": None, - }]) + self.assertEqual(requests, [ + { + "schema_ids": ["mesh.sync_alias_note.v1"], + "record_keys": ["note:remote"], + "shard_id": None, + "shard_epoch": None, + }, + { + "schema_ids": ["mesh.sync_alias_note.v1"], + "record_keys": ["note:remote"], + "shard_id": None, + "shard_epoch": None, + }, + ]) def test_cultmesh_node_emits_raw_put_and_delete_messages_for_local_writes(self) -> None: document = define_database_entry_type(