Skip to content

Commit aa08459

Browse files
authored
[HZ-5402] MultiMap for Asyncio (#787)
Straightforward port of asyncore MultiMap to asyncio. Does not include lock-related functions, since they are missing from the asyncio Map as well.
1 parent 73d3d48 commit aa08459

5 files changed

Lines changed: 697 additions & 4 deletions

File tree

hazelcast/internal/asyncio_client.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from hazelcast.internal.asyncio_compact import CompactSchemaService
88
from hazelcast.config import Config, IndexConfig
99
from hazelcast.internal.asyncio_connection import ConnectionManager, DefaultAsyncioAddressProvider
10-
from hazelcast.core import DistributedObjectEvent, DistributedObjectInfo
10+
from hazelcast.core import DistributedObjectEvent
1111
from hazelcast.discovery import HazelcastCloudAddressProvider
1212
from hazelcast.errors import IllegalStateError, InvalidConfigurationError
1313
from hazelcast.internal.asyncio_invocation import InvocationService, Invocation
@@ -18,20 +18,20 @@
1818
from hazelcast.internal.asyncio_partition import PartitionService, InternalPartitionService
1919
from hazelcast.protocol.codec import (
2020
client_add_distributed_object_listener_codec,
21-
client_get_distributed_objects_codec,
2221
client_remove_distributed_object_listener_codec,
2322
dynamic_config_add_vector_collection_config_codec,
2423
)
2524
from hazelcast.internal.asyncio_proxy.manager import (
2625
LIST_SERVICE,
2726
MAP_SERVICE,
27+
MULTI_MAP_SERVICE,
2828
ProxyManager,
2929
REPLICATED_MAP_SERVICE,
3030
VECTOR_SERVICE,
3131
)
32-
from hazelcast.internal.asyncio_proxy.base import Proxy
3332
from hazelcast.internal.asyncio_proxy.list import List
3433
from hazelcast.internal.asyncio_proxy.map import Map
34+
from hazelcast.internal.asyncio_proxy.multi_map import MultiMap
3535
from hazelcast.internal.asyncio_proxy.replicated_map import ReplicatedMap
3636
from hazelcast.internal.asyncio_reactor import AsyncioReactor
3737
from hazelcast.serialization import SerializationServiceV1
@@ -274,6 +274,17 @@ async def get_map(self, name: str) -> Map[KeyType, ValueType]:
274274
"""
275275
return await self._proxy_manager.get_or_create(MAP_SERVICE, name)
276276

277+
async def get_multi_map(self, name: str) -> MultiMap[KeyType, ValueType]:
278+
"""Returns the distributed MultiMap instance with the specified name.
279+
280+
Args:
281+
name: Name of the distributed MultiMap.
282+
283+
Returns:
284+
Distributed MultiMap instance with the specified name.
285+
"""
286+
return await self._proxy_manager.get_or_create(MULTI_MAP_SERVICE, name)
287+
277288
async def get_replicated_map(self, name: str) -> ReplicatedMap[KeyType, ValueType]:
278289
"""Returns the distributed ReplicatedMap instance with the specified
279290
name.

hazelcast/internal/asyncio_proxy/manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import typing
33

44
from hazelcast.internal.asyncio_proxy.list import create_list_proxy
5+
from hazelcast.internal.asyncio_proxy.multi_map import create_multi_map_proxy
56
from hazelcast.internal.asyncio_proxy.vector_collection import (
67
VectorCollection,
78
create_vector_collection_proxy,
@@ -15,6 +16,7 @@
1516

1617
LIST_SERVICE = "hz:impl:listService"
1718
MAP_SERVICE = "hz:impl:mapService"
19+
MULTI_MAP_SERVICE = "hz:impl:multiMapService"
1820
REPLICATED_MAP_SERVICE = "hz:impl:replicatedMapService"
1921
VECTOR_SERVICE = "hz:service:vector"
2022

@@ -24,6 +26,7 @@
2426
] = {
2527
LIST_SERVICE: create_list_proxy,
2628
MAP_SERVICE: create_map_proxy,
29+
MULTI_MAP_SERVICE: create_multi_map_proxy,
2730
REPLICATED_MAP_SERVICE: create_replicated_map_proxy,
2831
VECTOR_SERVICE: create_vector_collection_proxy,
2932
}

0 commit comments

Comments
 (0)