mirror of
https://github.com/umap-project/umap.git
synced 2025-05-01 04:22:24 +02:00
- Operations are now stored locally in memory. All operations are tied to an HLC (Hybrid Logical Clock), making it possible to order them concistently. - Messages are handled in their `on*` methods, leading to a clearer implementation. - When a new peer joins, it asks a random peer for the list of operations, and re-apply them locally. - Messages types names have been updated to follow CamelCase, and to be similar across the client and the server. - Pass `sync=False` to `makeFeature` in the updaters, to avoid generating duplicate operations on message retrieval.
22 lines
696 B
Python
22 lines
696 B
Python
from umap.websocket_server import OperationMessage, PeerMessage, Request, ServerRequest
|
|
|
|
|
|
def test_messages_are_parsed_correctly():
|
|
server = Request.model_validate(dict(kind="Server", action="list-peers")).root
|
|
assert type(server) is ServerRequest
|
|
|
|
operation = Request.model_validate(
|
|
dict(
|
|
kind="OperationMessage",
|
|
verb="upsert",
|
|
subject="map",
|
|
metadata={},
|
|
key="key",
|
|
)
|
|
).root
|
|
assert type(operation) is OperationMessage
|
|
|
|
peer_message = Request.model_validate(
|
|
dict(kind="PeerMessage", sender="Alice", recipient="Bob", message={})
|
|
).root
|
|
assert type(peer_message) is PeerMessage
|