Skip to content

Commit 15a9697

Browse files
authored
ReplicatedMap Proxy for Asyncio Client (#783)
Straightforward port of ReplicatedMap proxy and its tests to the Asyncio Client
1 parent 26a7467 commit 15a9697

5 files changed

Lines changed: 730 additions & 1 deletion

File tree

hazelcast/asyncio/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
warnings.warn("Asyncio API for Hazelcast Python Client is BETA. DO NOT use it in production.")
44
del warnings
55

6-
__all__ = ["EntryEventCallable", "HazelcastClient", "List", "Map", "VectorCollection"]
6+
__all__ = [
7+
"EntryEventCallable",
8+
"HazelcastClient",
9+
"List",
10+
"Map",
11+
"ReplicatedMap",
12+
"VectorCollection",
13+
]
714

815
from hazelcast.internal.asyncio_client import HazelcastClient
916
from hazelcast.internal.asyncio_proxy.list import List
1017
from hazelcast.internal.asyncio_proxy.map import Map, EntryEventCallable
18+
from hazelcast.internal.asyncio_proxy.replicated_map import ReplicatedMap
1119
from hazelcast.internal.asyncio_proxy.vector_collection import VectorCollection

hazelcast/internal/asyncio_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
LIST_SERVICE,
2727
MAP_SERVICE,
2828
ProxyManager,
29+
REPLICATED_MAP_SERVICE,
2930
VECTOR_SERVICE,
3031
)
3132
from hazelcast.internal.asyncio_proxy.base import Proxy
3233
from hazelcast.internal.asyncio_proxy.list import List
3334
from hazelcast.internal.asyncio_proxy.map import Map
35+
from hazelcast.internal.asyncio_proxy.replicated_map import ReplicatedMap
3436
from hazelcast.internal.asyncio_reactor import AsyncioReactor
3537
from hazelcast.serialization import SerializationServiceV1
3638
from hazelcast.internal.asyncio_statistics import Statistics
@@ -272,6 +274,18 @@ async def get_map(self, name: str) -> Map[KeyType, ValueType]:
272274
"""
273275
return await self._proxy_manager.get_or_create(MAP_SERVICE, name)
274276

277+
async def get_replicated_map(self, name: str) -> ReplicatedMap[KeyType, ValueType]:
278+
"""Returns the distributed ReplicatedMap instance with the specified
279+
name.
280+
281+
Args:
282+
name: Name of the distributed replicated map.
283+
284+
Returns:
285+
Distributed ReplicatedMap instance with the specified name.
286+
"""
287+
return await self._proxy_manager.get_or_create(REPLICATED_MAP_SERVICE, name)
288+
275289
async def create_vector_collection_config(
276290
self,
277291
name: str,

hazelcast/internal/asyncio_proxy/manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
from hazelcast.internal.asyncio_invocation import Invocation
1111
from hazelcast.internal.asyncio_proxy.base import Proxy
1212
from hazelcast.internal.asyncio_proxy.map import create_map_proxy
13+
from hazelcast.internal.asyncio_proxy.replicated_map import create_replicated_map_proxy
1314
from hazelcast.util import to_list
1415

1516
LIST_SERVICE = "hz:impl:listService"
1617
MAP_SERVICE = "hz:impl:mapService"
18+
REPLICATED_MAP_SERVICE = "hz:impl:replicatedMapService"
1719
VECTOR_SERVICE = "hz:service:vector"
1820

1921
_proxy_init: typing.Dict[
@@ -22,6 +24,7 @@
2224
] = {
2325
LIST_SERVICE: create_list_proxy,
2426
MAP_SERVICE: create_map_proxy,
27+
REPLICATED_MAP_SERVICE: create_replicated_map_proxy,
2528
VECTOR_SERVICE: create_vector_collection_proxy,
2629
}
2730

0 commit comments

Comments
 (0)