jararaca 0.3.5__py3-none-any.whl → 0.3.7__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.
Potentially problematic release.
This version of jararaca might be problematic. Click here for more details.
- jararaca/cli.py +9 -1
- jararaca/messagebus/worker.py +11 -13
- jararaca/messagebus/worker_v2.py +13 -6
- jararaca/utils/rabbitmq_utils.py +16 -8
- {jararaca-0.3.5.dist-info → jararaca-0.3.7.dist-info}/METADATA +1 -1
- {jararaca-0.3.5.dist-info → jararaca-0.3.7.dist-info}/RECORD +9 -9
- {jararaca-0.3.5.dist-info → jararaca-0.3.7.dist-info}/LICENSE +0 -0
- {jararaca-0.3.5.dist-info → jararaca-0.3.7.dist-info}/WHEEL +0 -0
- {jararaca-0.3.5.dist-info → jararaca-0.3.7.dist-info}/entry_points.txt +0 -0
jararaca/cli.py
CHANGED
|
@@ -102,6 +102,11 @@ def cli() -> None:
|
|
|
102
102
|
type=int,
|
|
103
103
|
default=1,
|
|
104
104
|
)
|
|
105
|
+
@click.option(
|
|
106
|
+
"--passive-declare",
|
|
107
|
+
is_flag=True,
|
|
108
|
+
default=False,
|
|
109
|
+
)
|
|
105
110
|
def worker(
|
|
106
111
|
app_path: str,
|
|
107
112
|
url: str,
|
|
@@ -109,6 +114,7 @@ def worker(
|
|
|
109
114
|
password: str | None,
|
|
110
115
|
exchange: str,
|
|
111
116
|
prefetch_count: int,
|
|
117
|
+
passive_declare: bool,
|
|
112
118
|
) -> None:
|
|
113
119
|
|
|
114
120
|
app = find_microservice_by_module_path(app_path)
|
|
@@ -141,7 +147,9 @@ def worker(
|
|
|
141
147
|
prefetch_count=prefetch_count,
|
|
142
148
|
)
|
|
143
149
|
|
|
144
|
-
worker_v1.MessageBusWorker(app, config=config).start_sync(
|
|
150
|
+
worker_v1.MessageBusWorker(app, config=config).start_sync(
|
|
151
|
+
passive_declare=passive_declare,
|
|
152
|
+
)
|
|
145
153
|
|
|
146
154
|
|
|
147
155
|
@cli.command()
|
jararaca/messagebus/worker.py
CHANGED
|
@@ -91,7 +91,7 @@ class AioPikaMicroserviceConsumer:
|
|
|
91
91
|
self.lock = asyncio.Lock()
|
|
92
92
|
self.tasks: set[asyncio.Task[Any]] = set()
|
|
93
93
|
|
|
94
|
-
async def consume(self) -> None:
|
|
94
|
+
async def consume(self, passive_declare: bool) -> None:
|
|
95
95
|
|
|
96
96
|
connection = await aio_pika.connect(self.config.url)
|
|
97
97
|
|
|
@@ -99,14 +99,13 @@ class AioPikaMicroserviceConsumer:
|
|
|
99
99
|
|
|
100
100
|
await channel.set_qos(prefetch_count=self.config.prefetch_count)
|
|
101
101
|
|
|
102
|
-
main_ex = await
|
|
103
|
-
name=self.config.exchange, ensure=False
|
|
104
|
-
) or await RabbitmqUtils.declare_main_exchange(
|
|
102
|
+
main_ex = await RabbitmqUtils.declare_main_exchange(
|
|
105
103
|
channel=channel,
|
|
106
104
|
exchange_name=self.config.exchange,
|
|
105
|
+
passive=passive_declare,
|
|
107
106
|
)
|
|
108
107
|
|
|
109
|
-
dlx, dlq = await RabbitmqUtils.
|
|
108
|
+
dlx, dlq = await RabbitmqUtils.declare_dl_kit(channel=channel)
|
|
110
109
|
|
|
111
110
|
for handler in self.message_handler_set:
|
|
112
111
|
|
|
@@ -115,10 +114,9 @@ class AioPikaMicroserviceConsumer:
|
|
|
115
114
|
|
|
116
115
|
self.incoming_map[queue_name] = handler
|
|
117
116
|
|
|
118
|
-
queue = await channel.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
queue_name,
|
|
117
|
+
queue: aio_pika.abc.AbstractQueue = await channel.declare_queue(
|
|
118
|
+
passive=passive_declare,
|
|
119
|
+
name=queue_name,
|
|
122
120
|
arguments={
|
|
123
121
|
"x-dead-letter-exchange": dlx.name,
|
|
124
122
|
"x-dead-letter-routing-key": dlq.name,
|
|
@@ -332,7 +330,7 @@ class MessageBusWorker:
|
|
|
332
330
|
raise RuntimeError("Consumer not started")
|
|
333
331
|
return self._consumer
|
|
334
332
|
|
|
335
|
-
async def start_async(self) -> None:
|
|
333
|
+
async def start_async(self, passive_declare: bool) -> None:
|
|
336
334
|
all_message_handlers_set: MESSAGE_HANDLER_DATA_SET = set()
|
|
337
335
|
async with self.lifecycle():
|
|
338
336
|
for instance_type in self.app.controllers:
|
|
@@ -369,9 +367,9 @@ class MessageBusWorker:
|
|
|
369
367
|
uow_context_provider=self.uow_context_provider,
|
|
370
368
|
)
|
|
371
369
|
|
|
372
|
-
await consumer.consume()
|
|
370
|
+
await consumer.consume(passive_declare=passive_declare)
|
|
373
371
|
|
|
374
|
-
def start_sync(self) -> None:
|
|
372
|
+
def start_sync(self, passive_declare: bool) -> None:
|
|
375
373
|
|
|
376
374
|
def on_shutdown(loop: asyncio.AbstractEventLoop) -> None:
|
|
377
375
|
logger.info("Shutting down")
|
|
@@ -381,7 +379,7 @@ class MessageBusWorker:
|
|
|
381
379
|
runner.get_loop().add_signal_handler(
|
|
382
380
|
signal.SIGINT, on_shutdown, runner.get_loop()
|
|
383
381
|
)
|
|
384
|
-
runner.run(self.start_async())
|
|
382
|
+
runner.run(self.start_async(passive_declare=passive_declare))
|
|
385
383
|
|
|
386
384
|
|
|
387
385
|
class AioPikaMessageBusController(BusMessageController):
|
jararaca/messagebus/worker_v2.py
CHANGED
|
@@ -112,6 +112,7 @@ class AioPikaMicroserviceConsumer(MessageBusConsumer):
|
|
|
112
112
|
message_handler_set: MESSAGE_HANDLER_DATA_SET,
|
|
113
113
|
scheduled_actions: SCHEDULED_ACTION_DATA_SET,
|
|
114
114
|
uow_context_provider: UnitOfWorkContextProvider,
|
|
115
|
+
passive_declare: bool = False,
|
|
115
116
|
):
|
|
116
117
|
|
|
117
118
|
self.broker_backend = broker_backend
|
|
@@ -123,6 +124,7 @@ class AioPikaMicroserviceConsumer(MessageBusConsumer):
|
|
|
123
124
|
self.shutdown_event = asyncio.Event()
|
|
124
125
|
self.lock = asyncio.Lock()
|
|
125
126
|
self.tasks: set[asyncio.Task[Any]] = set()
|
|
127
|
+
self.passive_declare = passive_declare
|
|
126
128
|
|
|
127
129
|
async def consume(self) -> None:
|
|
128
130
|
|
|
@@ -135,11 +137,16 @@ class AioPikaMicroserviceConsumer(MessageBusConsumer):
|
|
|
135
137
|
await RabbitmqUtils.declare_main_exchange(
|
|
136
138
|
channel=channel,
|
|
137
139
|
exchange_name=self.config.exchange,
|
|
140
|
+
passive=self.passive_declare,
|
|
138
141
|
)
|
|
139
142
|
|
|
140
|
-
dlx = await RabbitmqUtils.declare_dl_exchange(
|
|
143
|
+
dlx = await RabbitmqUtils.declare_dl_exchange(
|
|
144
|
+
channel=channel, passive=self.passive_declare
|
|
145
|
+
)
|
|
141
146
|
|
|
142
|
-
dlq = await RabbitmqUtils.declare_dl_queue(
|
|
147
|
+
dlq = await RabbitmqUtils.declare_dl_queue(
|
|
148
|
+
channel=channel, passive=self.passive_declare
|
|
149
|
+
)
|
|
143
150
|
|
|
144
151
|
await dlq.bind(dlx, routing_key=RabbitmqUtils.DEAD_LETTER_EXCHANGE)
|
|
145
152
|
|
|
@@ -151,7 +158,7 @@ class AioPikaMicroserviceConsumer(MessageBusConsumer):
|
|
|
151
158
|
self.incoming_map[queue_name] = handler
|
|
152
159
|
|
|
153
160
|
queue = await RabbitmqUtils.declare_queue(
|
|
154
|
-
channel=channel, queue_name=queue_name
|
|
161
|
+
channel=channel, queue_name=queue_name, passive=self.passive_declare
|
|
155
162
|
)
|
|
156
163
|
|
|
157
164
|
await queue.bind(exchange=self.config.exchange, routing_key=routing_key)
|
|
@@ -174,9 +181,9 @@ class AioPikaMicroserviceConsumer(MessageBusConsumer):
|
|
|
174
181
|
|
|
175
182
|
routing_key = queue_name
|
|
176
183
|
|
|
177
|
-
queue = await
|
|
178
|
-
|
|
179
|
-
)
|
|
184
|
+
queue = await RabbitmqUtils.declare_queue(
|
|
185
|
+
channel=channel, queue_name=queue_name, passive=self.passive_declare
|
|
186
|
+
)
|
|
180
187
|
|
|
181
188
|
await queue.bind(exchange=self.config.exchange, routing_key=routing_key)
|
|
182
189
|
|
jararaca/utils/rabbitmq_utils.py
CHANGED
|
@@ -7,20 +7,25 @@ class RabbitmqUtils:
|
|
|
7
7
|
DEAD_LETTER_QUEUE = "dlq"
|
|
8
8
|
|
|
9
9
|
@classmethod
|
|
10
|
-
async def declare_dl_exchange(
|
|
10
|
+
async def declare_dl_exchange(
|
|
11
|
+
cls, channel: AbstractChannel, passive: bool
|
|
12
|
+
) -> AbstractExchange:
|
|
11
13
|
"""
|
|
12
14
|
Declare a Dead Letter Exchange (DLX) for the given channel.
|
|
13
15
|
"""
|
|
14
16
|
await channel.set_qos(prefetch_count=1)
|
|
15
17
|
return await channel.declare_exchange(
|
|
16
18
|
cls.DEAD_LETTER_EXCHANGE,
|
|
19
|
+
passive=passive,
|
|
17
20
|
type="direct",
|
|
18
21
|
durable=True,
|
|
19
22
|
auto_delete=False,
|
|
20
23
|
)
|
|
21
24
|
|
|
22
25
|
@classmethod
|
|
23
|
-
async def declare_dl_queue(
|
|
26
|
+
async def declare_dl_queue(
|
|
27
|
+
cls, channel: AbstractChannel, passive: bool
|
|
28
|
+
) -> AbstractQueue:
|
|
24
29
|
"""
|
|
25
30
|
Declare a Dead Letter Queue (DLQ) for the given queue.
|
|
26
31
|
"""
|
|
@@ -28,6 +33,7 @@ class RabbitmqUtils:
|
|
|
28
33
|
return await channel.declare_queue(
|
|
29
34
|
cls.DEAD_LETTER_QUEUE,
|
|
30
35
|
durable=True,
|
|
36
|
+
passive=passive,
|
|
31
37
|
arguments={
|
|
32
38
|
"x-dead-letter-exchange": "",
|
|
33
39
|
"x-dead-letter-routing-key": cls.DEAD_LETTER_EXCHANGE,
|
|
@@ -35,23 +41,22 @@ class RabbitmqUtils:
|
|
|
35
41
|
)
|
|
36
42
|
|
|
37
43
|
@classmethod
|
|
38
|
-
async def
|
|
44
|
+
async def declare_dl_kit(
|
|
39
45
|
cls,
|
|
40
46
|
channel: AbstractChannel,
|
|
47
|
+
passive: bool = False,
|
|
41
48
|
) -> tuple[AbstractExchange, AbstractQueue]:
|
|
42
49
|
"""
|
|
43
50
|
Declare a Dead Letter Exchange and Queue (DLX and DLQ) for the given channel.
|
|
44
51
|
"""
|
|
45
|
-
dlx = await cls.declare_dl_exchange(channel)
|
|
46
|
-
dlq = await cls.declare_dl_queue(channel)
|
|
52
|
+
dlx = await cls.declare_dl_exchange(channel, passive=passive)
|
|
53
|
+
dlq = await cls.declare_dl_queue(channel, passive=passive)
|
|
47
54
|
await dlq.bind(dlx, routing_key=cls.DEAD_LETTER_EXCHANGE)
|
|
48
55
|
return dlx, dlq
|
|
49
56
|
|
|
50
57
|
@classmethod
|
|
51
58
|
async def declare_main_exchange(
|
|
52
|
-
cls,
|
|
53
|
-
channel: AbstractChannel,
|
|
54
|
-
exchange_name: str,
|
|
59
|
+
cls, channel: AbstractChannel, exchange_name: str, passive: bool
|
|
55
60
|
) -> AbstractExchange:
|
|
56
61
|
"""
|
|
57
62
|
Declare a main exchange for the given channel.
|
|
@@ -59,6 +64,7 @@ class RabbitmqUtils:
|
|
|
59
64
|
await channel.set_qos(prefetch_count=1)
|
|
60
65
|
return await channel.declare_exchange(
|
|
61
66
|
exchange_name,
|
|
67
|
+
passive=passive,
|
|
62
68
|
type="topic",
|
|
63
69
|
durable=True,
|
|
64
70
|
auto_delete=False,
|
|
@@ -69,6 +75,7 @@ class RabbitmqUtils:
|
|
|
69
75
|
cls,
|
|
70
76
|
channel: AbstractChannel,
|
|
71
77
|
queue_name: str,
|
|
78
|
+
passive: bool = False,
|
|
72
79
|
) -> AbstractQueue:
|
|
73
80
|
"""
|
|
74
81
|
Declare a queue with the given name and properties.
|
|
@@ -76,6 +83,7 @@ class RabbitmqUtils:
|
|
|
76
83
|
await channel.set_qos(prefetch_count=1)
|
|
77
84
|
return await channel.declare_queue(
|
|
78
85
|
queue_name,
|
|
86
|
+
passive=passive,
|
|
79
87
|
durable=True,
|
|
80
88
|
arguments={
|
|
81
89
|
"x-dead-letter-exchange": cls.DEAD_LETTER_EXCHANGE,
|
|
@@ -3,7 +3,7 @@ jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
|
|
|
3
3
|
jararaca/broker_backend/__init__.py,sha256=GzEIuHR1xzgCJD4FE3harNjoaYzxHMHoEL0_clUaC-k,3528
|
|
4
4
|
jararaca/broker_backend/mapper.py,sha256=vTsi7sWpNvlga1PWPFg0rCJ5joJ0cdzykkIc2Tuvenc,696
|
|
5
5
|
jararaca/broker_backend/redis_broker_backend.py,sha256=a7DHchy3NAiD71Ix8SwmQOUnniu7uup-Woa4ON_4J7I,5786
|
|
6
|
-
jararaca/cli.py,sha256=
|
|
6
|
+
jararaca/cli.py,sha256=jHn9ohHuBr1Jt-i8MtQq644EK3rzu11AJGMsLaLdYg4,10396
|
|
7
7
|
jararaca/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
jararaca/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
jararaca/core/providers.py,sha256=wktH84FK7c1s2wNq-fudf1uMfi3CQBR0neU2czJ_L0U,434
|
|
@@ -20,8 +20,8 @@ jararaca/messagebus/interceptors/aiopika_publisher_interceptor.py,sha256=Aex87wo
|
|
|
20
20
|
jararaca/messagebus/interceptors/publisher_interceptor.py,sha256=fQFFW9hH6ZU3UOyR7kMPrNp9wA71qEy5XlgrBQdBMS4,1230
|
|
21
21
|
jararaca/messagebus/message.py,sha256=U6cyd2XknX8mtm0333slz5fanky2PFLWCmokAO56vvU,819
|
|
22
22
|
jararaca/messagebus/publisher.py,sha256=K7WsOMVTyLmdms3ZKEshqrQc_DhNreiFK-HnmOT9Ce0,1965
|
|
23
|
-
jararaca/messagebus/worker.py,sha256=
|
|
24
|
-
jararaca/messagebus/worker_v2.py,sha256=
|
|
23
|
+
jararaca/messagebus/worker.py,sha256=2jReCepgMQktdLh4A3OqmOmx6KNgqUGpXIOXoBUtXSg,13778
|
|
24
|
+
jararaca/messagebus/worker_v2.py,sha256=Ey9HPgVSuIYJUggJGPKmgymZHz7-2TUSYgDB52u9T10,20683
|
|
25
25
|
jararaca/microservice.py,sha256=C_Txqm3xSmdHIghJigKk6TOycL5eTJv9PF6XP7TA8j4,6638
|
|
26
26
|
jararaca/observability/decorators.py,sha256=XffBinFXdiNkY6eo8_1nkr_GapM0RUGBg0aicBIelag,2220
|
|
27
27
|
jararaca/observability/interceptor.py,sha256=GHkuGKFWftN7MDjvYeGFGEPnuJETNhtxRK6yuPrCrpU,1462
|
|
@@ -65,9 +65,9 @@ jararaca/tools/app_config/interceptor.py,sha256=nfFZiS80hrbnL7-XEYrwmp2rwaVYBqxv
|
|
|
65
65
|
jararaca/tools/metadata.py,sha256=7nlCDYgItNybentPSSCc2MLqN7IpBd0VyQzfjfQycVI,1402
|
|
66
66
|
jararaca/tools/typescript/interface_parser.py,sha256=_4cqte3OMAiHP-dPqUCWzWar4Ur04F-0x4ZUEnSTN-c,30040
|
|
67
67
|
jararaca/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
|
-
jararaca/utils/rabbitmq_utils.py,sha256=
|
|
69
|
-
jararaca-0.3.
|
|
70
|
-
jararaca-0.3.
|
|
71
|
-
jararaca-0.3.
|
|
72
|
-
jararaca-0.3.
|
|
73
|
-
jararaca-0.3.
|
|
68
|
+
jararaca/utils/rabbitmq_utils.py,sha256=FPDP8ZVgvitZXV-oK73D7EIANsqUzXTW7HdpEKsIsyI,2811
|
|
69
|
+
jararaca-0.3.7.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
70
|
+
jararaca-0.3.7.dist-info/METADATA,sha256=91LMUP1lkRvrHrVttwT6NSXZ5xWISWNo-ZFsL5BjTMU,4951
|
|
71
|
+
jararaca-0.3.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
72
|
+
jararaca-0.3.7.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
|
|
73
|
+
jararaca-0.3.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|