Skip to content

Commit 4b42713

Browse files
committed
Ported PNCounter to asyncio
1 parent 0b838ef commit 4b42713

5 files changed

Lines changed: 500 additions & 1 deletion

File tree

hazelcast/asyncio/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,28 @@
55

66
__all__ = [
77
"EntryEventCallable",
8+
"Executor",
89
"HazelcastClient",
910
"List",
1011
"Map",
12+
"MultiMap",
13+
"PNCounter",
14+
"Queue",
1115
"ReplicatedMap",
16+
"Ringbuffer",
17+
"Set",
1218
"VectorCollection",
1319
]
1420

1521
from hazelcast.internal.asyncio_client import HazelcastClient
22+
from hazelcast.internal.asyncio_proxy.executor import Executor
1623
from hazelcast.internal.asyncio_proxy.list import List
1724
from hazelcast.internal.asyncio_proxy.map import Map, EntryEventCallable
25+
from hazelcast.internal.asyncio_proxy.multi_map import MultiMap
26+
from hazelcast.internal.asyncio_proxy.pn_counter import PNCounter
27+
from hazelcast.internal.asyncio_proxy.queue import Queue
1828
from hazelcast.internal.asyncio_proxy.replicated_map import ReplicatedMap
29+
from hazelcast.internal.asyncio_proxy.replicated_map import ReplicatedMap
30+
from hazelcast.internal.asyncio_proxy.ringbuffer import Ringbuffer
31+
from hazelcast.internal.asyncio_proxy.set import Set
1932
from hazelcast.internal.asyncio_proxy.vector_collection import VectorCollection

hazelcast/internal/asyncio_client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from hazelcast.discovery import HazelcastCloudAddressProvider
1212
from hazelcast.errors import IllegalStateError, InvalidConfigurationError
1313
from hazelcast.internal.asyncio_invocation import InvocationService, Invocation
14+
from hazelcast.internal.asyncio_proxy.pn_counter import PNCounter
1415
from hazelcast.internal.asyncio_proxy.vector_collection import VectorCollection
1516
from hazelcast.lifecycle import LifecycleService, LifecycleState, _InternalLifecycleService
1617
from hazelcast.internal.asyncio_listener import ClusterViewListenerService, ListenerService
@@ -31,7 +32,7 @@
3132
REPLICATED_MAP_SERVICE,
3233
RINGBUFFER_SERVICE,
3334
SET_SERVICE,
34-
VECTOR_SERVICE,
35+
VECTOR_SERVICE, PN_COUNTER_SERVICE,
3536
)
3637
from hazelcast.internal.asyncio_proxy.base import Proxy
3738
from hazelcast.internal.asyncio_proxy.executor import Executor
@@ -350,6 +351,17 @@ async def get_ringbuffer(self, name: str) -> Ringbuffer[ItemType]:
350351
"""
351352
return await self._proxy_manager.get_or_create(RINGBUFFER_SERVICE, name)
352353

354+
async def get_pn_counter(self, name: str) -> PNCounter:
355+
"""Returns the PN Counter instance with the specified name.
356+
357+
Args:
358+
name: Name of the PN Counter.
359+
360+
Returns:
361+
Distributed PN Counter instance with the specified name.
362+
"""
363+
return await self._proxy_manager.get_or_create(PN_COUNTER_SERVICE, name)
364+
353365
async def create_vector_collection_config(
354366
self,
355367
name: str,

hazelcast/internal/asyncio_proxy/manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from hazelcast.internal.asyncio_proxy.executor import create_executor_proxy
55
from hazelcast.internal.asyncio_proxy.list import create_list_proxy
66
from hazelcast.internal.asyncio_proxy.multi_map import create_multi_map_proxy
7+
from hazelcast.internal.asyncio_proxy.pn_counter import create_pn_counter_proxy
78
from hazelcast.internal.asyncio_proxy.queue import create_queue_proxy
89
from hazelcast.internal.asyncio_proxy.set import create_set_proxy
910
from hazelcast.internal.asyncio_proxy.vector_collection import (
@@ -25,6 +26,7 @@
2526
REPLICATED_MAP_SERVICE = "hz:impl:replicatedMapService"
2627
RINGBUFFER_SERVICE = "hz:impl:ringbufferService"
2728
SET_SERVICE = "hz:impl:setService"
29+
PN_COUNTER_SERVICE = "hz:impl:PNCounterService"
2830
VECTOR_SERVICE = "hz:service:vector"
2931

3032
_proxy_init: typing.Dict[
@@ -39,6 +41,7 @@
3941
REPLICATED_MAP_SERVICE: create_replicated_map_proxy,
4042
RINGBUFFER_SERVICE: create_ringbuffer_proxy,
4143
SET_SERVICE: create_set_proxy,
44+
PN_COUNTER_SERVICE: create_pn_counter_proxy,
4245
VECTOR_SERVICE: create_vector_collection_proxy,
4346
}
4447

0 commit comments

Comments
 (0)