busline 0.5.0__py3-none-any.whl → 0.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- busline/client/pubsub_client.py +24 -1
- busline/client/subscriber/topic_subscriber.py +5 -2
- busline/local/subscriber/local_subscriber.py +3 -0
- {busline-0.5.0.dist-info → busline-0.5.2.dist-info}/METADATA +4 -4
- {busline-0.5.0.dist-info → busline-0.5.2.dist-info}/RECORD +8 -8
- {busline-0.5.0.dist-info → busline-0.5.2.dist-info}/WHEEL +1 -1
- {busline-0.5.0.dist-info → busline-0.5.2.dist-info}/licenses/LICENSE +0 -0
- {busline-0.5.0.dist-info → busline-0.5.2.dist-info}/top_level.txt +0 -0
busline/client/pubsub_client.py
CHANGED
@@ -4,6 +4,8 @@ from typing import Optional, override, List, Self
|
|
4
4
|
|
5
5
|
from busline.client.client import EventBusClient
|
6
6
|
from busline.client.publisher.publisher import Publisher
|
7
|
+
from busline.client.subscriber.event_handler.event_handler import EventHandler
|
8
|
+
from busline.client.subscriber.topic_subscriber import TopicSubscriber
|
7
9
|
from busline.event.event import Event
|
8
10
|
from busline.client.subscriber.subscriber import Subscriber
|
9
11
|
|
@@ -33,7 +35,7 @@ class PubSubClient(EventBusClient):
|
|
33
35
|
return cls(publishers, subscribers)
|
34
36
|
|
35
37
|
@classmethod
|
36
|
-
def from_pubsub_client(cls, client:
|
38
|
+
def from_pubsub_client(cls, client: Self) -> Self:
|
37
39
|
return cls(client.publishers.copy(), client.subscribers.copy())
|
38
40
|
|
39
41
|
@override
|
@@ -89,6 +91,27 @@ class PubSubClient(EventBusClient):
|
|
89
91
|
])
|
90
92
|
|
91
93
|
|
94
|
+
@dataclass
|
95
|
+
class PubSubTopicClient(PubSubClient):
|
96
|
+
"""
|
97
|
+
Eventbus client which should used by components which wouldn't be a publisher/subscriber, but they need them
|
98
|
+
|
99
|
+
Author: Nicola Ricciardi
|
100
|
+
"""
|
101
|
+
|
102
|
+
subscribers: List[TopicSubscriber]
|
103
|
+
|
104
|
+
@override
|
105
|
+
async def subscribe(self, topic: str, handler: Optional[EventHandler] = None, **kwargs):
|
106
|
+
"""
|
107
|
+
Subscribe all subscribers on topic
|
108
|
+
"""
|
109
|
+
|
110
|
+
await asyncio.gather(*[
|
111
|
+
subscriber.subscribe(topic, handler=handler, **kwargs) for subscriber in self.subscribers
|
112
|
+
])
|
113
|
+
|
114
|
+
|
92
115
|
@dataclass
|
93
116
|
class PubSubClientBuilder:
|
94
117
|
"""
|
@@ -44,12 +44,15 @@ class TopicSubscriber(Subscriber, ABC):
|
|
44
44
|
self.handlers[topic] = handler
|
45
45
|
|
46
46
|
@override
|
47
|
-
async def _on_unsubscribed(self, topic: str
|
47
|
+
async def _on_unsubscribed(self, topic: Optional[str], **kwargs):
|
48
48
|
|
49
49
|
if topic is None:
|
50
50
|
self.handlers = {}
|
51
51
|
else:
|
52
|
-
|
52
|
+
if topic in self.handlers:
|
53
|
+
del self.handlers[topic]
|
54
|
+
else:
|
55
|
+
logging.warning(f"{self}: unsubscribed from unknown topic: {topic}")
|
53
56
|
|
54
57
|
def __get_handlers_of_topic(self, topic: str) -> List[EventHandler]:
|
55
58
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: busline
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Agnostic eventbus for Python
|
5
5
|
Author-email: Nicola Ricciardi <ricciardincl@gmail.com>
|
6
|
-
Project-URL: Homepage, https://github.com/
|
7
|
-
Project-URL: Issues, https://github.com/
|
6
|
+
Project-URL: Homepage, https://github.com/orbitalis-framework/py-busline
|
7
|
+
Project-URL: Issues, https://github.com/orbitalis-framework/py-busline/issues
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
9
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
10
10
|
Classifier: Operating System :: OS Independent
|
11
|
-
Requires-Python: >=3.
|
11
|
+
Requires-Python: >=3.12
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
14
|
Dynamic: license-file
|
@@ -4,12 +4,12 @@ busline/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
busline/client/client.py,sha256=4IGMJXp_46cPOXJaMeix45rUkxRNlSFJXch2hLy0C70,553
|
5
5
|
busline/client/eventbus_connector.py,sha256=V3D5f4bddlQW1oiZzjvNTsVa0yIHAjYHG03YV3zwz5c,596
|
6
6
|
busline/client/multiclient.py,sha256=QnKK8ShrwbuS1fnsXVhRgMnBzIbPgnDkBPGjswDilR8,1251
|
7
|
-
busline/client/pubsub_client.py,sha256=
|
7
|
+
busline/client/pubsub_client.py,sha256=nkDNhP8M5ULi76YCY35BshuKsvRJH3vsU5ZO5qSmTTA,4161
|
8
8
|
busline/client/publisher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
busline/client/publisher/publisher.py,sha256=FUht2eeV25lrQzgHxB0OjijEGUiTSan8AEjb-IqYjX8,1521
|
10
10
|
busline/client/subscriber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
busline/client/subscriber/subscriber.py,sha256=QHMEi6PbzoiY6SywVGPjOBUL86PD3OYRVH6fCTeZPfw,2713
|
12
|
-
busline/client/subscriber/topic_subscriber.py,sha256=
|
12
|
+
busline/client/subscriber/topic_subscriber.py,sha256=sxhISxKqIH6lvdk_MnHBjHAcwKSwJO65KaiLD4SdNWE,3306
|
13
13
|
busline/client/subscriber/event_handler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
busline/client/subscriber/event_handler/closure_event_handler.py,sha256=YvgHEDgsWkW5shZ4r11pPSXnPotcXcr56xQQJDnkmxg,497
|
15
15
|
busline/client/subscriber/event_handler/event_handler.py,sha256=az-zyJpZykowWN9M0x7PzO1qsUUOgVcEqi15crX8txc,296
|
@@ -28,9 +28,9 @@ busline/local/eventbus/local_eventbus.py,sha256=2wK2NMlWXm_9CTYR39y7Z40C8yOQ8RdV
|
|
28
28
|
busline/local/publisher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
29
|
busline/local/publisher/local_publisher.py,sha256=FngthjSMZyswYK2Ka1LHrTqFkZ6yvGUjn0COGEzI0hI,1076
|
30
30
|
busline/local/subscriber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
busline/local/subscriber/local_subscriber.py,sha256=
|
32
|
-
busline-0.5.
|
33
|
-
busline-0.5.
|
34
|
-
busline-0.5.
|
35
|
-
busline-0.5.
|
36
|
-
busline-0.5.
|
31
|
+
busline/local/subscriber/local_subscriber.py,sha256=GIHlumOlMtTHw_TGof24JcAz6rT3VE7ywhLkVrM2TOM,1264
|
32
|
+
busline-0.5.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
33
|
+
busline-0.5.2.dist-info/METADATA,sha256=4M-mXVToBVGPB3uBUYt4BpVyEYYTOeEHIT_MUi9cB0k,5923
|
34
|
+
busline-0.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
35
|
+
busline-0.5.2.dist-info/top_level.txt,sha256=bZY0fK2wgNEI5igR7DBF3CyXHGkzujGvmoqdSzG6Zp0,8
|
36
|
+
busline-0.5.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|