busline 0.5.2__py3-none-any.whl → 0.5.3__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.
@@ -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
@@ -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)
@@ -7,9 +7,6 @@ from busline.local.eventbus.eventbus import EventBus
7
7
  from busline.exceptions import EventBusClientNotConnected
8
8
 
9
9
 
10
- ALL_TOPIC_WILDCARD = "*"
11
-
12
-
13
10
  @dataclass
14
11
  class LocalEventBusSubscriber(TopicSubscriber):
15
12
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: busline
3
- Version: 0.5.2
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
@@ -4,7 +4,7 @@ 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=nkDNhP8M5ULi76YCY35BshuKsvRJH3vsU5ZO5qSmTTA,4161
7
+ busline/client/pubsub_client.py,sha256=1-Fk-FTvn_oSJ_wEDJOnjjS2X_6PM6hRctKUdP8QyA8,4491
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
@@ -19,7 +19,7 @@ busline/event/event.py,sha256=a1-COH-0hOwFQnbFpwWWJHpr0GqwsyV0JUgqPiI4iRs,1308
19
19
  busline/event/registry.py,sha256=2Yr-UE7rOuJGEawsybfKiK1HZUNxyDovlaXJh0tdct8,1709
20
20
  busline/event/test.py,sha256=SkPH0IB3x5WbJCv6dr_wP_dP8_-mQRz9MRWnipHzBDY,1361
21
21
  busline/local/__init__.py,sha256=th_6FPU7d8l4CQ_Rp21FM7NCLMFBWkt0Cyy6mCMJeUY,125
22
- busline/local/local_pubsub_client.py,sha256=F8IK83PgmRUV1pBqCv6BhF0YQn_B9nn18DmSVTFdwnk,1698
22
+ busline/local/local_pubsub_client.py,sha256=M_h0905kZy5KwC3vXGc9zpWAX_pEuAVavVDULNy5II4,3078
23
23
  busline/local/test.py,sha256=HxJBNWBqY-0L7salT_XzILF2i6WMCitnGO8LwQx6D8o,4438
24
24
  busline/local/eventbus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  busline/local/eventbus/async_local_eventbus.py,sha256=aettYF1W7G3agKVneGMU6kBr_-Gy2M10Lx40vQ2k66M,649
@@ -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=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,,
31
+ busline/local/subscriber/local_subscriber.py,sha256=tWQ5YCRH78wiFlwO6I_dSAvCyhkQLox0GhoeVPKWxro,1237
32
+ busline-0.5.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
33
+ busline-0.5.3.dist-info/METADATA,sha256=FKWXvhaMwCRUk9X5CzpQbLq_TfCfEhgdIbImmjVpZcE,5923
34
+ busline-0.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
35
+ busline-0.5.3.dist-info/top_level.txt,sha256=bZY0fK2wgNEI5igR7DBF3CyXHGkzujGvmoqdSzG6Zp0,8
36
+ busline-0.5.3.dist-info/RECORD,,