Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hazelcast/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
warnings.warn("Asyncio API for Hazelcast Python Client is BETA. DO NOT use it in production.")
del warnings

__all__ = ["EntryEventCallable", "HazelcastClient", "Map", "VectorCollection"]
__all__ = ["EntryEventCallable", "HazelcastClient", "List", "Map", "VectorCollection"]

from hazelcast.internal.asyncio_client import HazelcastClient
from hazelcast.internal.asyncio_proxy.list import List
from hazelcast.internal.asyncio_proxy.map import Map, EntryEventCallable
from hazelcast.internal.asyncio_proxy.vector_collection import VectorCollection
13 changes: 13 additions & 0 deletions hazelcast/internal/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
dynamic_config_add_vector_collection_config_codec,
)
from hazelcast.internal.asyncio_proxy.manager import (
LIST_SERVICE,
MAP_SERVICE,
ProxyManager,
VECTOR_SERVICE,
)
from hazelcast.internal.asyncio_proxy.base import Proxy
from hazelcast.internal.asyncio_proxy.list import List
from hazelcast.internal.asyncio_proxy.map import Map
from hazelcast.internal.asyncio_reactor import AsyncioReactor
from hazelcast.serialization import SerializationServiceV1
Expand Down Expand Up @@ -248,6 +250,17 @@ async def _start(self):
raise
_logger.info("Client started")

async def get_list(self, name: str) -> List[KeyType]:
"""Returns the distributed list instance with the specified name.

Args:
name: Name of the distributed list.

Returns:
Distributed list instance with the specified name.
"""
return await self._proxy_manager.get_or_create(LIST_SERVICE, name)

async def get_map(self, name: str) -> Map[KeyType, ValueType]:
"""Returns the distributed map instance with the specified name.

Expand Down
13 changes: 13 additions & 0 deletions hazelcast/internal/asyncio_proxy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from hazelcast.core import MemberInfo
from hazelcast.types import KeyType, ValueType, ItemType, MessageType, BlockingProxyType
from hazelcast.internal.asyncio_invocation import Invocation
from hazelcast.internal.asyncio_partition import string_partition_strategy
from hazelcast.util import get_attr_name

MAX_SIZE = float("inf")
Expand Down Expand Up @@ -91,6 +92,18 @@ async def _ainvoke_on_partition(
return await fut


class PartitionSpecificProxy(Proxy, abc.ABC):
"""Provides basic functionality for Partition Specific Proxies."""

def __init__(self, service_name, name, context):
super(PartitionSpecificProxy, self).__init__(service_name, name, context)
partition_key = context.serialization_service.to_data(string_partition_strategy(name))
self._partition_id = context.partition_service.get_partition_id(partition_key)

def _invoke(self, request, response_handler=_no_op_response_handler) -> asyncio.Future:
return self._invoke_on_partition(request, self._partition_id, response_handler)


class ItemEventType:
"""Type of item events."""

Expand Down
Loading