jararaca 0.3.11a10__py3-none-any.whl → 0.3.11a11__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/__init__.py CHANGED
@@ -79,7 +79,6 @@ if TYPE_CHECKING:
79
79
  )
80
80
  from .messagebus.message import Message, MessageOf
81
81
  from .messagebus.publisher import use_publisher
82
- from .messagebus.worker import MessageBusWorker
83
82
  from .microservice import (
84
83
  Microservice,
85
84
  use_app_context,
@@ -215,7 +214,6 @@ if TYPE_CHECKING:
215
214
  "AIOSqlAlchemySessionInterceptor",
216
215
  "AIOSQAConfig",
217
216
  "create_http_server",
218
- "MessageBusWorker",
219
217
  "Container",
220
218
  "WebSocketInterceptor",
221
219
  "use_session",
@@ -367,7 +365,6 @@ _dynamic_imports: "dict[str, tuple[str, str, str | None]]" = {
367
365
  None,
368
366
  ),
369
367
  "create_http_server": (__SPEC_PARENT__, "presentation.server", None),
370
- "MessageBusWorker": (__SPEC_PARENT__, "messagebus.worker", None),
371
368
  "Container": (__SPEC_PARENT__, "di", None),
372
369
  "WebSocketInterceptor": (
373
370
  __SPEC_PARENT__,
jararaca/cli.py CHANGED
@@ -8,23 +8,21 @@ import time
8
8
  from codecs import StreamWriter
9
9
  from pathlib import Path
10
10
  from typing import Any
11
- from urllib.parse import parse_qs, urlparse, urlunsplit
11
+ from urllib.parse import parse_qs, urlparse
12
12
 
13
13
  import aio_pika
14
14
  import click
15
15
  import uvicorn
16
16
  from mako.template import Template
17
17
 
18
- from jararaca.messagebus import worker as worker_v1
19
- from jararaca.messagebus import worker_v2 as worker_v2_mod
18
+ from jararaca.messagebus import worker as worker_mod
20
19
  from jararaca.messagebus.decorators import MessageBusController, MessageHandler
21
20
  from jararaca.microservice import Microservice
22
21
  from jararaca.presentation.http_microservice import HttpMicroservice
23
22
  from jararaca.presentation.server import create_http_server
24
23
  from jararaca.reflect.controller_inspect import inspect_controller
24
+ from jararaca.scheduler.beat_worker import BeatWorker
25
25
  from jararaca.scheduler.decorators import ScheduledAction
26
- from jararaca.scheduler.scheduler import Scheduler
27
- from jararaca.scheduler.scheduler_v2 import SchedulerV2
28
26
  from jararaca.tools.typescript.interface_parser import (
29
27
  write_microservice_to_typescript_interface,
30
28
  )
@@ -183,98 +181,6 @@ def cli() -> None:
183
181
  pass
184
182
 
185
183
 
186
- @cli.command()
187
- @click.argument(
188
- "app_path",
189
- type=str,
190
- )
191
- @click.option(
192
- "--url",
193
- type=str,
194
- envvar="BROKER_URL",
195
- )
196
- @click.option(
197
- "--username",
198
- type=str,
199
- default=None,
200
- )
201
- @click.option(
202
- "--password",
203
- type=str,
204
- default=None,
205
- )
206
- @click.option(
207
- "--exchange",
208
- type=str,
209
- default="jararaca_ex",
210
- )
211
- @click.option(
212
- "--prefetch-count",
213
- type=int,
214
- default=1,
215
- )
216
- @click.option(
217
- "--passive-declare",
218
- is_flag=True,
219
- default=False,
220
- help="[DEPRECATED] Use passive declarations (check if infrastructure exists without creating it)",
221
- )
222
- @click.option(
223
- "--handlers",
224
- type=str,
225
- help="Comma-separated list of handler names to listen to. If not specified, all handlers will be used.",
226
- )
227
- def worker(
228
- app_path: str,
229
- url: str,
230
- username: str | None,
231
- password: str | None,
232
- exchange: str,
233
- prefetch_count: int,
234
- handlers: str | None,
235
- passive_declare: bool,
236
- ) -> None:
237
-
238
- app = find_microservice_by_module_path(app_path)
239
-
240
- parsed_url = urlparse(url)
241
-
242
- if password is not None:
243
- parsed_url = urlparse(
244
- urlunsplit(
245
- parsed_url._replace(
246
- netloc=f"{parsed_url.username or ''}:{password}@{parsed_url.netloc}"
247
- )
248
- )
249
- )
250
-
251
- if username is not None:
252
- parsed_url = urlparse(
253
- urlunsplit(
254
- parsed_url._replace(
255
- netloc=f"{username}{':%s' % password if password is not None else ''}@{parsed_url.netloc}"
256
- )
257
- )
258
- )
259
-
260
- url = parsed_url.geturl()
261
-
262
- # Parse handler names if provided
263
- handler_names: set[str] | None = None
264
- if handlers:
265
- handler_names = {name.strip() for name in handlers.split(",") if name.strip()}
266
-
267
- config = worker_v1.AioPikaWorkerConfig(
268
- url=url,
269
- exchange=exchange,
270
- prefetch_count=prefetch_count,
271
- )
272
-
273
- worker_v1.MessageBusWorker(app, config=config).start_sync(
274
- handler_names=handler_names,
275
- )
276
-
277
-
278
184
  @cli.command()
279
185
  @click.argument(
280
186
  "app_path",
@@ -285,21 +191,25 @@ def worker(
285
191
  "--broker-url",
286
192
  type=str,
287
193
  envvar="BROKER_URL",
194
+ required=True,
195
+ help="The URL for the message broker",
288
196
  )
289
197
  @click.option(
290
198
  "--backend-url",
291
199
  type=str,
292
200
  envvar="BACKEND_URL",
201
+ required=True,
202
+ help="The URL for the message broker backend",
293
203
  )
294
204
  @click.option(
295
205
  "--handlers",
296
206
  type=str,
297
207
  help="Comma-separated list of handler names to listen to. If not specified, all handlers will be used.",
298
208
  )
299
- def worker_v2(
209
+ def worker(
300
210
  app_path: str, broker_url: str, backend_url: str, handlers: str | None
301
211
  ) -> None:
302
-
212
+ """Start a message bus worker that processes asynchronous messages from a message queue."""
303
213
  app = find_microservice_by_module_path(app_path)
304
214
 
305
215
  # Parse handler names if provided
@@ -307,7 +217,7 @@ def worker_v2(
307
217
  if handlers:
308
218
  handler_names = {name.strip() for name in handlers.split(",") if name.strip()}
309
219
 
310
- worker_v2_mod.MessageBusWorker(
220
+ worker_mod.MessageBusWorker(
311
221
  app=app,
312
222
  broker_url=broker_url,
313
223
  backend_url=backend_url,
@@ -354,38 +264,6 @@ def server(app_path: str, host: str, port: int) -> None:
354
264
  uvicorn.run(asgi_app, host=host, port=port)
355
265
 
356
266
 
357
- @cli.command()
358
- @click.argument(
359
- "app_path",
360
- type=str,
361
- )
362
- @click.option(
363
- "--interval",
364
- type=int,
365
- default=1,
366
- )
367
- @click.option(
368
- "--schedulers",
369
- type=str,
370
- help="Comma-separated list of scheduler names to run (only run schedulers with these names)",
371
- )
372
- def scheduler(
373
- app_path: str,
374
- interval: int,
375
- schedulers: str | None = None,
376
- ) -> None:
377
- app = find_microservice_by_module_path(app_path)
378
-
379
- # Parse scheduler names if provided
380
- scheduler_names: set[str] | None = None
381
- if schedulers:
382
- scheduler_names = {
383
- name.strip() for name in schedulers.split(",") if name.strip()
384
- }
385
-
386
- Scheduler(app, interval=interval, scheduler_names=scheduler_names).run()
387
-
388
-
389
267
  @cli.command()
390
268
  @click.argument(
391
269
  "app_path",
@@ -408,35 +286,33 @@ def scheduler(
408
286
  required=True,
409
287
  )
410
288
  @click.option(
411
- "--schedulers",
289
+ "--actions",
412
290
  type=str,
413
- help="Comma-separated list of scheduler names to run (only run schedulers with these names)",
291
+ help="Comma-separated list of action names to run (only run actions with these names)",
414
292
  )
415
- def scheduler_v2(
293
+ def beat(
416
294
  interval: int,
417
295
  broker_url: str,
418
296
  backend_url: str,
419
297
  app_path: str,
420
- schedulers: str | None = None,
298
+ actions: str | None = None,
421
299
  ) -> None:
422
300
 
423
301
  app = find_microservice_by_module_path(app_path)
424
302
 
425
303
  # Parse scheduler names if provided
426
304
  scheduler_names: set[str] | None = None
427
- if schedulers:
428
- scheduler_names = {
429
- name.strip() for name in schedulers.split(",") if name.strip()
430
- }
305
+ if actions:
306
+ scheduler_names = {name.strip() for name in actions.split(",") if name.strip()}
431
307
 
432
- scheduler = SchedulerV2(
308
+ beat_worker = BeatWorker(
433
309
  app=app,
434
310
  interval=interval,
435
311
  backend_url=backend_url,
436
312
  broker_url=broker_url,
437
- scheduler_names=scheduler_names,
313
+ scheduled_action_names=scheduler_names,
438
314
  )
439
- scheduler.run()
315
+ beat_worker.run()
440
316
 
441
317
 
442
318
  def generate_interfaces(