busline 0.5.1__tar.gz → 0.5.3__tar.gz

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.
Files changed (40) hide show
  1. {busline-0.5.1 → busline-0.5.3}/PKG-INFO +2 -2
  2. {busline-0.5.1 → busline-0.5.3}/busline/client/pubsub_client.py +17 -1
  3. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/topic_subscriber.py +5 -2
  4. {busline-0.5.1 → busline-0.5.3}/busline/local/local_pubsub_client.py +51 -1
  5. {busline-0.5.1 → busline-0.5.3}/busline.egg-info/PKG-INFO +2 -2
  6. {busline-0.5.1 → busline-0.5.3}/pyproject.toml +2 -2
  7. {busline-0.5.1 → busline-0.5.3}/LICENSE +0 -0
  8. {busline-0.5.1 → busline-0.5.3}/README.md +0 -0
  9. {busline-0.5.1 → busline-0.5.3}/busline/__init__.py +0 -0
  10. {busline-0.5.1 → busline-0.5.3}/busline/client/__init__.py +0 -0
  11. {busline-0.5.1 → busline-0.5.3}/busline/client/client.py +0 -0
  12. {busline-0.5.1 → busline-0.5.3}/busline/client/eventbus_connector.py +0 -0
  13. {busline-0.5.1 → busline-0.5.3}/busline/client/multiclient.py +0 -0
  14. {busline-0.5.1 → busline-0.5.3}/busline/client/publisher/__init__.py +0 -0
  15. {busline-0.5.1 → busline-0.5.3}/busline/client/publisher/publisher.py +0 -0
  16. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/__init__.py +0 -0
  17. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/event_handler/__init__.py +0 -0
  18. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/event_handler/closure_event_handler.py +0 -0
  19. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/event_handler/event_handler.py +0 -0
  20. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/event_handler/multi_handler.py +0 -0
  21. {busline-0.5.1 → busline-0.5.3}/busline/client/subscriber/subscriber.py +0 -0
  22. {busline-0.5.1 → busline-0.5.3}/busline/event/__init__.py +0 -0
  23. {busline-0.5.1 → busline-0.5.3}/busline/event/event.py +0 -0
  24. {busline-0.5.1 → busline-0.5.3}/busline/event/registry.py +0 -0
  25. {busline-0.5.1 → busline-0.5.3}/busline/event/test.py +0 -0
  26. {busline-0.5.1 → busline-0.5.3}/busline/exceptions.py +0 -0
  27. {busline-0.5.1 → busline-0.5.3}/busline/local/__init__.py +0 -0
  28. {busline-0.5.1 → busline-0.5.3}/busline/local/eventbus/__init__.py +0 -0
  29. {busline-0.5.1 → busline-0.5.3}/busline/local/eventbus/async_local_eventbus.py +0 -0
  30. {busline-0.5.1 → busline-0.5.3}/busline/local/eventbus/eventbus.py +0 -0
  31. {busline-0.5.1 → busline-0.5.3}/busline/local/eventbus/local_eventbus.py +0 -0
  32. {busline-0.5.1 → busline-0.5.3}/busline/local/publisher/__init__.py +0 -0
  33. {busline-0.5.1 → busline-0.5.3}/busline/local/publisher/local_publisher.py +0 -0
  34. {busline-0.5.1 → busline-0.5.3}/busline/local/subscriber/__init__.py +0 -0
  35. {busline-0.5.1 → busline-0.5.3}/busline/local/subscriber/local_subscriber.py +0 -0
  36. {busline-0.5.1 → busline-0.5.3}/busline/local/test.py +0 -0
  37. {busline-0.5.1 → busline-0.5.3}/busline.egg-info/SOURCES.txt +0 -0
  38. {busline-0.5.1 → busline-0.5.3}/busline.egg-info/dependency_links.txt +0 -0
  39. {busline-0.5.1 → busline-0.5.3}/busline.egg-info/top_level.txt +0 -0
  40. {busline-0.5.1 → busline-0.5.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: busline
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Agnostic eventbus for Python
5
5
  Author-email: Nicola Ricciardi <ricciardincl@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/orbitalis-framework/py-busline
@@ -8,7 +8,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.8
11
+ Requires-Python: >=3.12
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Dynamic: license-file
@@ -92,7 +92,7 @@ class PubSubClient(EventBusClient):
92
92
 
93
93
 
94
94
  @dataclass
95
- class PubSubTopicClient(PubSubClient):
95
+ class PubTopicSubClient(PubSubClient):
96
96
  """
97
97
  Eventbus client which should used by components which wouldn't be a publisher/subscriber, but they need them
98
98
 
@@ -149,3 +149,19 @@ class PubSubClientBuilder:
149
149
  def build(self) -> PubSubClient:
150
150
  return self.base_client
151
151
 
152
+
153
+ @dataclass
154
+ class PubTopicSubClientBuilder(PubSubClientBuilder):
155
+ """
156
+
157
+ Author: Nicola Ricciardi
158
+ """
159
+
160
+ base_client: PubTopicSubClient = field(
161
+ default_factory=lambda: PubTopicSubClient([], []),
162
+ kw_only=True
163
+ )
164
+
165
+ @override
166
+ def build(self) -> PubTopicSubClient:
167
+ return self.base_client
@@ -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 | None, **kwargs):
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
- del self.handlers[topic]
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
 
@@ -3,7 +3,7 @@ from dataclasses import dataclass, field
3
3
  from busline.client.publisher.publisher import Publisher
4
4
  from busline.client.subscriber.event_handler.closure_event_handler import ClosureEventHandler
5
5
  from busline.event.event import Event
6
- from busline.client.pubsub_client import PubSubClient, PubSubClientBuilder
6
+ from busline.client.pubsub_client import PubSubClient, PubSubClientBuilder, PubTopicSubClient
7
7
  from busline.local.eventbus.eventbus import EventBus
8
8
  from busline.local.eventbus.local_eventbus import LocalEventBus
9
9
  from busline.local.publisher.local_publisher import LocalEventBusPublisher
@@ -15,6 +15,11 @@ class LocalPubSubClient(PubSubClient):
15
15
  pass
16
16
 
17
17
 
18
+ @dataclass
19
+ class LocalPubTopicSubClient(PubTopicSubClient):
20
+ pass
21
+
22
+
18
23
  @dataclass
19
24
  class LocalPubSubClientBuilder(PubSubClientBuilder):
20
25
  """
@@ -26,6 +31,10 @@ class LocalPubSubClientBuilder(PubSubClientBuilder):
26
31
  """
27
32
 
28
33
  eventbus: EventBus = field(default_factory=LocalEventBus)
34
+ base_client: LocalPubSubClient = field(
35
+ default_factory=lambda: LocalPubSubClient([], []),
36
+ kw_only=True
37
+ )
29
38
 
30
39
  def with_default_publisher(self) -> Self:
31
40
  """"
@@ -52,3 +61,44 @@ class LocalPubSubClientBuilder(PubSubClientBuilder):
52
61
  def build(self) -> LocalPubSubClient:
53
62
  return LocalPubSubClient.from_pubsub_client(self.base_client)
54
63
 
64
+
65
+ @dataclass
66
+ class LocalPubTopicSubClientBuilder(PubSubClientBuilder):
67
+ """
68
+ Builder for a local pub/sub client.
69
+
70
+ EventBus fed in init will be used to build publishers and subscribers
71
+
72
+ Author: Nicola Ricciardi
73
+ """
74
+
75
+ eventbus: EventBus = field(default_factory=LocalEventBus)
76
+ base_client: LocalPubTopicSubClient = field(
77
+ default_factory=lambda: LocalPubTopicSubClient([], []),
78
+ kw_only=True
79
+ )
80
+
81
+ def with_default_publisher(self) -> Self:
82
+ """"
83
+ LocalEventBusPublisher coupled with eventbus is used
84
+ """
85
+
86
+ self.base_client.publishers.append(
87
+ LocalEventBusPublisher(eventbus=self.eventbus)
88
+ )
89
+
90
+ return self
91
+
92
+ def with_closure_subscriber(self, closure: Callable[[str, Event], None]) -> Self:
93
+ self.base_client.subscribers.append(
94
+ LocalEventBusSubscriber(
95
+ eventbus=self.eventbus,
96
+ fallback_event_handler=ClosureEventHandler(closure)
97
+ )
98
+ )
99
+
100
+ return self
101
+
102
+ @override
103
+ def build(self) -> LocalPubTopicSubClient:
104
+ return LocalPubTopicSubClient.from_pubsub_client(self.base_client)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: busline
3
- Version: 0.5.1
3
+ Version: 0.5.3
4
4
  Summary: Agnostic eventbus for Python
5
5
  Author-email: Nicola Ricciardi <ricciardincl@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/orbitalis-framework/py-busline
@@ -8,7 +8,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.8
11
+ Requires-Python: >=3.12
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Dynamic: license-file
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "busline"
3
- version = "0.5.1"
3
+ version = "0.5.3"
4
4
  authors = [
5
5
  { name="Nicola Ricciardi", email="ricciardincl@gmail.com" },
6
6
  ]
7
7
  description = "Agnostic eventbus for Python"
8
8
  readme = "README.md"
9
- requires-python = ">=3.8"
9
+ requires-python = ">=3.12"
10
10
  classifiers = [
11
11
  "Programming Language :: Python :: 3",
12
12
  "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes