jararaca 0.3.11a11__py3-none-any.whl → 0.3.11a13__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 +47 -46
- jararaca/scheduler/beat_worker.py +1 -1
- jararaca/utils/rabbitmq_utils.py +5 -56
- {jararaca-0.3.11a11.dist-info → jararaca-0.3.11a13.dist-info}/METADATA +1 -1
- {jararaca-0.3.11a11.dist-info → jararaca-0.3.11a13.dist-info}/RECORD +8 -8
- {jararaca-0.3.11a11.dist-info → jararaca-0.3.11a13.dist-info}/LICENSE +0 -0
- {jararaca-0.3.11a11.dist-info → jararaca-0.3.11a13.dist-info}/WHEEL +0 -0
- {jararaca-0.3.11a11.dist-info → jararaca-0.3.11a13.dist-info}/entry_points.txt +0 -0
jararaca/cli.py
CHANGED
|
@@ -78,6 +78,7 @@ async def declare_worker_infrastructure(
|
|
|
78
78
|
broker_url: str,
|
|
79
79
|
app: Microservice,
|
|
80
80
|
force: bool = False,
|
|
81
|
+
interactive_mode: bool = False,
|
|
81
82
|
) -> None:
|
|
82
83
|
"""
|
|
83
84
|
Declare the infrastructure (exchanges and queues) for worker.
|
|
@@ -100,25 +101,32 @@ async def declare_worker_infrastructure(
|
|
|
100
101
|
connection = await aio_pika.connect(broker_url)
|
|
101
102
|
channel = await connection.channel()
|
|
102
103
|
|
|
103
|
-
#
|
|
104
|
-
if force:
|
|
105
|
-
click.echo(f"→
|
|
104
|
+
# Only force delete infrastructure if requested at the beginning
|
|
105
|
+
if force or (interactive_mode and click.confirm(f"Delete existing infrastructure for exchange: {exchange}?")):
|
|
106
|
+
click.echo(f"→ Deleting existing infrastructure for exchange: {exchange}")
|
|
106
107
|
await RabbitmqUtils.delete_exchange(channel, exchange)
|
|
107
108
|
await RabbitmqUtils.delete_exchange(channel, RabbitmqUtils.DEAD_LETTER_EXCHANGE)
|
|
108
109
|
await RabbitmqUtils.delete_queue(channel, RabbitmqUtils.DEAD_LETTER_QUEUE)
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
try:
|
|
112
|
+
await RabbitmqUtils.declare_main_exchange(
|
|
113
|
+
channel=channel,
|
|
114
|
+
exchange_name=exchange,
|
|
115
|
+
passive=False,
|
|
116
|
+
)
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
dlx = await RabbitmqUtils.declare_dl_exchange(channel=channel, passive=False)
|
|
119
|
+
dlq = await RabbitmqUtils.declare_dl_queue(channel=channel, passive=False)
|
|
120
|
+
await dlq.bind(dlx, routing_key=RabbitmqUtils.DEAD_LETTER_EXCHANGE)
|
|
121
|
+
except Exception as e:
|
|
122
|
+
click.echo(f"Error during exchange declaration: {e}")
|
|
123
|
+
if force or (interactive_mode and click.confirm("Error occurred. Recreate infrastructure?")):
|
|
124
|
+
await channel.close()
|
|
125
|
+
await connection.close()
|
|
126
|
+
raise
|
|
127
|
+
click.echo("Skipping main exchange declaration due to error")
|
|
119
128
|
|
|
120
129
|
# Find all message handlers and scheduled actions
|
|
121
|
-
|
|
122
130
|
for instance_type in app.controllers:
|
|
123
131
|
controller_spec = MessageBusController.get_messagebus(instance_type)
|
|
124
132
|
if controller_spec is None:
|
|
@@ -127,50 +135,46 @@ async def declare_worker_infrastructure(
|
|
|
127
135
|
_, members = inspect_controller(instance_type)
|
|
128
136
|
|
|
129
137
|
# Declare queues for message handlers
|
|
130
|
-
for
|
|
131
|
-
|
|
138
|
+
for _, member in members.items():
|
|
132
139
|
message_handler = MessageHandler.get_message_incoming(
|
|
133
140
|
member.member_function
|
|
134
141
|
)
|
|
135
142
|
if message_handler is not None:
|
|
136
|
-
|
|
137
143
|
queue_name = f"{message_handler.message_type.MESSAGE_TOPIC}.{member.member_function.__module__}.{member.member_function.__qualname__}"
|
|
138
144
|
routing_key = f"{message_handler.message_type.MESSAGE_TOPIC}.#"
|
|
139
145
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
await RabbitmqUtils.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
f"
|
|
151
|
-
|
|
146
|
+
try:
|
|
147
|
+
# Try to declare queue
|
|
148
|
+
queue = await RabbitmqUtils.declare_worker_queue(
|
|
149
|
+
channel=channel, queue_name=queue_name, passive=False
|
|
150
|
+
)
|
|
151
|
+
await queue.bind(exchange=exchange, routing_key=routing_key)
|
|
152
|
+
click.echo(
|
|
153
|
+
f"✓ Declared message handler queue: {queue_name} (routing key: {routing_key})"
|
|
154
|
+
)
|
|
155
|
+
except Exception as e:
|
|
156
|
+
click.echo(f"⚠ Skipping message handler queue {queue_name} due to error: {e}")
|
|
157
|
+
continue
|
|
152
158
|
|
|
153
159
|
scheduled_action = ScheduledAction.get_scheduled_action(
|
|
154
160
|
member.member_function
|
|
155
161
|
)
|
|
156
162
|
if scheduled_action is not None:
|
|
157
|
-
|
|
158
|
-
# Declare queues for scheduled actions
|
|
159
|
-
|
|
160
163
|
queue_name = f"{member.member_function.__module__}.{member.member_function.__qualname__}"
|
|
161
164
|
routing_key = queue_name
|
|
162
165
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await RabbitmqUtils.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
166
|
+
try:
|
|
167
|
+
# Try to declare queue
|
|
168
|
+
queue = await RabbitmqUtils.declare_scheduled_action_queue(
|
|
169
|
+
channel=channel, queue_name=queue_name, passive=False
|
|
170
|
+
)
|
|
171
|
+
await queue.bind(exchange=exchange, routing_key=routing_key)
|
|
172
|
+
click.echo(
|
|
173
|
+
f"✓ Declared scheduled action queue: {queue_name} (routing key: {routing_key})"
|
|
174
|
+
)
|
|
175
|
+
except Exception as e:
|
|
176
|
+
click.echo(f"⚠ Skipping scheduled action queue {queue_name} due to error: {e}")
|
|
177
|
+
continue
|
|
174
178
|
|
|
175
179
|
await channel.close()
|
|
176
180
|
await connection.close()
|
|
@@ -539,6 +543,7 @@ def gen_entity(entity_name: str, file_path: StreamWriter) -> None:
|
|
|
539
543
|
@click.argument(
|
|
540
544
|
"app_path",
|
|
541
545
|
type=str,
|
|
546
|
+
envvar="APP_PATH",
|
|
542
547
|
)
|
|
543
548
|
@click.option(
|
|
544
549
|
"--broker-url",
|
|
@@ -642,13 +647,9 @@ def declare(
|
|
|
642
647
|
click.echo(
|
|
643
648
|
f"→ Declaring worker infrastructure (URL: {broker_url_with_exchange})"
|
|
644
649
|
)
|
|
645
|
-
click.echo(
|
|
646
|
-
f"→ Declaring scheduler infrastructure (URL: {broker_url_with_exchange})"
|
|
647
|
-
)
|
|
648
|
-
|
|
649
650
|
await declare_worker_infrastructure(broker_url_with_exchange, app, force)
|
|
650
651
|
|
|
651
|
-
click.echo("✓
|
|
652
|
+
click.echo("✓ Workers infrastructure declared successfully!")
|
|
652
653
|
except Exception as e:
|
|
653
654
|
click.echo(f"ERROR: Failed to declare infrastructure: {e}", err=True)
|
|
654
655
|
raise
|
|
@@ -195,7 +195,7 @@ class _RabbitMQBrokerDispatcher(_MessageBrokerDispatcher):
|
|
|
195
195
|
queue_name = ScheduledAction.get_function_id(sched_act_data.callable)
|
|
196
196
|
|
|
197
197
|
# Try to get existing queue
|
|
198
|
-
await RabbitmqUtils.
|
|
198
|
+
await RabbitmqUtils.get_scheduled_action_queue(
|
|
199
199
|
channel=channel,
|
|
200
200
|
queue_name=queue_name,
|
|
201
201
|
)
|
jararaca/utils/rabbitmq_utils.py
CHANGED
|
@@ -222,7 +222,7 @@ class RabbitmqUtils:
|
|
|
222
222
|
raise
|
|
223
223
|
|
|
224
224
|
@classmethod
|
|
225
|
-
async def
|
|
225
|
+
async def declare_worker_queue(
|
|
226
226
|
cls,
|
|
227
227
|
channel: AbstractChannel,
|
|
228
228
|
queue_name: str,
|
|
@@ -243,64 +243,13 @@ class RabbitmqUtils:
|
|
|
243
243
|
)
|
|
244
244
|
|
|
245
245
|
@classmethod
|
|
246
|
-
async def
|
|
246
|
+
async def get_scheduled_action_queue(
|
|
247
247
|
cls,
|
|
248
248
|
channel: AbstractChannel,
|
|
249
249
|
queue_name: str,
|
|
250
250
|
) -> AbstractQueue:
|
|
251
251
|
"""
|
|
252
|
-
Get a
|
|
253
|
-
"""
|
|
254
|
-
try:
|
|
255
|
-
return await channel.get_queue(queue_name)
|
|
256
|
-
except ChannelNotFoundEntity as e:
|
|
257
|
-
logger.error(
|
|
258
|
-
f"Worker queue '{queue_name}' does not exist. "
|
|
259
|
-
f"Please use the declare command to create it first. Error: {e}"
|
|
260
|
-
)
|
|
261
|
-
raise
|
|
262
|
-
except ChannelClosed as e:
|
|
263
|
-
logger.error(
|
|
264
|
-
f"Channel closed while getting worker queue '{queue_name}'. "
|
|
265
|
-
f"Error: {e}"
|
|
266
|
-
)
|
|
267
|
-
raise
|
|
268
|
-
except AMQPError as e:
|
|
269
|
-
logger.error(
|
|
270
|
-
f"AMQP error while getting worker queue '{queue_name}'. " f"Error: {e}"
|
|
271
|
-
)
|
|
272
|
-
raise
|
|
273
|
-
|
|
274
|
-
@classmethod
|
|
275
|
-
async def declare_worker_v1_queue(
|
|
276
|
-
cls,
|
|
277
|
-
channel: AbstractChannel,
|
|
278
|
-
queue_name: str,
|
|
279
|
-
dlx_name: str,
|
|
280
|
-
dlq_name: str,
|
|
281
|
-
passive: bool = False,
|
|
282
|
-
) -> AbstractQueue:
|
|
283
|
-
"""
|
|
284
|
-
Declare a worker v1 queue with custom dead letter exchange and routing key.
|
|
285
|
-
"""
|
|
286
|
-
return await channel.declare_queue(
|
|
287
|
-
passive=passive,
|
|
288
|
-
name=queue_name,
|
|
289
|
-
arguments={
|
|
290
|
-
"x-dead-letter-exchange": dlx_name,
|
|
291
|
-
"x-dead-letter-routing-key": dlq_name,
|
|
292
|
-
},
|
|
293
|
-
durable=True,
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
@classmethod
|
|
297
|
-
async def get_scheduler_queue(
|
|
298
|
-
cls,
|
|
299
|
-
channel: AbstractChannel,
|
|
300
|
-
queue_name: str,
|
|
301
|
-
) -> AbstractQueue:
|
|
302
|
-
"""
|
|
303
|
-
Get a scheduler queue.
|
|
252
|
+
Get a scheduled action queue.
|
|
304
253
|
"""
|
|
305
254
|
try:
|
|
306
255
|
return await channel.get_queue(queue_name)
|
|
@@ -324,14 +273,14 @@ class RabbitmqUtils:
|
|
|
324
273
|
raise
|
|
325
274
|
|
|
326
275
|
@classmethod
|
|
327
|
-
async def
|
|
276
|
+
async def declare_scheduled_action_queue(
|
|
328
277
|
cls,
|
|
329
278
|
channel: AbstractChannel,
|
|
330
279
|
queue_name: str,
|
|
331
280
|
passive: bool = False,
|
|
332
281
|
) -> AbstractQueue:
|
|
333
282
|
"""
|
|
334
|
-
Declare a
|
|
283
|
+
Declare a scheduled action queue with simple durable configuration.
|
|
335
284
|
The queue has a max length of 1 to ensure only one scheduled task
|
|
336
285
|
is processed at a time.
|
|
337
286
|
"""
|
|
@@ -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=pmwWDk7muP_BsDgWTcyiCOIhSbEJuuEoNFSiH2g27b4,19753
|
|
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
|
|
@@ -57,7 +57,7 @@ jararaca/rpc/http/backends/otel.py,sha256=Uc6CjHSCZ5hvnK1fNFv3ota5xzUFnvIl1JOpG3
|
|
|
57
57
|
jararaca/rpc/http/decorators.py,sha256=oUSzgMGI8w6SoKiz3GltDbd3BWAuyY60F23cdRRNeiw,11897
|
|
58
58
|
jararaca/rpc/http/httpx.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
jararaca/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
|
-
jararaca/scheduler/beat_worker.py,sha256=
|
|
60
|
+
jararaca/scheduler/beat_worker.py,sha256=JZXjkEMmZkvSwjfqgY4ClJE9Fwi6O-u2G_lHnjptVys,11605
|
|
61
61
|
jararaca/scheduler/decorators.py,sha256=iyWFvPLCRh9c0YReQRemI2mLuaUv7r929So-xuKIWUs,4605
|
|
62
62
|
jararaca/scheduler/types.py,sha256=4HEQOmVIDp-BYLSzqmqSFIio1bd51WFmgFPIzPpVu04,135
|
|
63
63
|
jararaca/tools/app_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -65,9 +65,9 @@ jararaca/tools/app_config/decorators.py,sha256=-ckkMZ1dswOmECdo1rFrZ15UAku--txaN
|
|
|
65
65
|
jararaca/tools/app_config/interceptor.py,sha256=HV8h4AxqUc_ACs5do4BSVlyxlRXzx7HqJtoVO9tfRnQ,2611
|
|
66
66
|
jararaca/tools/typescript/interface_parser.py,sha256=35xbOrZDQDyTXdMrVZQ8nnFw79f28lJuLYNHAspIqi8,30492
|
|
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=ytdAFUyv-OBkaVnxezuJaJoLrmN7giZgtKeet_IsMBs,10918
|
|
69
|
+
jararaca-0.3.11a13.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
70
|
+
jararaca-0.3.11a13.dist-info/METADATA,sha256=akkZ-YQwyNhyiFNRgvBCooSVevh2SlRmNH5I_tdeJCE,4998
|
|
71
|
+
jararaca-0.3.11a13.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
72
|
+
jararaca-0.3.11a13.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
|
|
73
|
+
jararaca-0.3.11a13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|