qena-shared-lib 0.1.13__tar.gz → 0.1.15__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 (45) hide show
  1. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/.pre-commit-config.yaml +8 -8
  2. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/CHANGELOG.md +17 -0
  3. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/PKG-INFO +7 -9
  4. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/README.md +6 -8
  5. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/pyproject.toml +1 -1
  6. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/logging.py +0 -6
  7. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_base.py +20 -21
  8. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/utils.py +10 -0
  9. qena_shared_lib-0.1.13/requirements.txt +0 -55
  10. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/.gitignore +0 -0
  11. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/__init__.py +0 -0
  12. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/application.py +0 -0
  13. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/background.py +0 -0
  14. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/__init__.py +0 -0
  15. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/http.py +0 -0
  16. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/miscellaneous.py +0 -0
  17. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/exception_handlers.py +0 -0
  18. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/exceptions.py +0 -0
  19. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/http.py +0 -0
  20. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/py.typed +0 -0
  21. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/__init__.py +0 -0
  22. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_channel.py +0 -0
  23. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_exception_handlers.py +0 -0
  24. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_listener.py +0 -0
  25. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_pool.py +0 -0
  26. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_publisher.py +0 -0
  27. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_rpc_client.py +0 -0
  28. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/__init__.py +0 -0
  29. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/_base.py +0 -0
  30. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/__init__.py +0 -0
  31. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_base.py +0 -0
  32. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_http_sender.py +0 -0
  33. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_tcp_sender.py +0 -0
  34. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/scheduler.py +0 -0
  35. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/src/qena_shared_lib/security.py +0 -0
  36. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/conftest.py +0 -0
  37. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_application.py +0 -0
  38. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_background.py +0 -0
  39. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_dependencies.py +0 -0
  40. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_logstash.py +0 -0
  41. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_rabbitmq.py +0 -0
  42. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_scheduler.py +0 -0
  43. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/test_security.py +0 -0
  44. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/tests/utils.py +0 -0
  45. {qena_shared_lib-0.1.13 → qena_shared_lib-0.1.15}/uv.lock +0 -0
@@ -1,12 +1,12 @@
1
1
  repos:
2
- - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v5.0.0
4
- hooks:
5
- - id: check-added-large-files
6
- - id: check-toml
7
- - id: check-yaml
8
- - id: end-of-file-fixer
9
- - id: trailing-whitespace
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ - id: check-toml
7
+ - id: check-yaml
8
+ - id: end-of-file-fixer
9
+ - id: trailing-whitespace
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
11
  rev: v0.9.9
12
12
  hooks:
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.15] - 2025-06-28
4
+
5
+ ### Changed
6
+
7
+ - Removed logger level set by dafault
8
+
9
+
10
+ ## [0.1.14] - 2025-06-16
11
+
12
+ ### Changed
13
+
14
+ - Remove unused generics variables
15
+ - Remove requirements.txt
16
+
17
+
3
18
  ## [0.1.13] - 2025-06-16
4
19
 
5
20
  ### Added
@@ -22,5 +37,7 @@
22
37
  - Added a re-export for rabbitmq channel pool (ChannelPool) class.
23
38
 
24
39
 
40
+ [0.1.15]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.14...v0.1.15
41
+ [0.1.14]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.13...v0.1.14
25
42
  [0.1.13]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.12...v0.1.13
26
43
  [0.1.12]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.11...v0.1.12
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qena-shared-lib
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: A shared tools for other services
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: cronsim==2.6
@@ -51,6 +51,7 @@ def main() -> FastAPI:
51
51
  .with_description("A shared tools for other services.")
52
52
  .with_version("0.1.0")
53
53
  .with_environment(Environment.PRODUCTION)
54
+ .with_default_exception_handlers()
54
55
  )
55
56
 
56
57
  app = builder.build()
@@ -131,9 +132,7 @@ class UserController(ControllerBase):
131
132
  def main() -> FastAPI:
132
133
  ...
133
134
 
134
- builder.with_controllers([
135
- UserController
136
- ])
135
+ builder.with_controllers(UserController)
137
136
 
138
137
  ...
139
138
  ```
@@ -161,9 +160,7 @@ async def login(
161
160
  def main() -> FastAPI:
162
161
  ...
163
162
 
164
- builder.with_routers([
165
- router
166
- ])
163
+ builder.with_routers(router)
167
164
 
168
165
  ...
169
166
  ```
@@ -270,6 +267,7 @@ def main() -> FastAPI:
270
267
  container=builder.container,
271
268
  )
272
269
 
270
+ rabbitmq.init_default_exception_handlers()
273
271
  rabbitmq.include_listener(UserConsumer)
274
272
  builder.add_singleton(
275
273
  service=RabbitMqManager,
@@ -293,7 +291,7 @@ async def store_user(
293
291
  publisher = rabbitmq.publisher("UserQueue")
294
292
 
295
293
  await publisher.publish(user)
296
- # await publisher.publish_with_arguments(user)
294
+ # await publisher.publish_as_arguments(user)
297
295
  ```
298
296
 
299
297
  ### RPC client
@@ -625,7 +623,7 @@ class UserController(ControllerBase):
625
623
  UserInfo,
626
624
  Authorization(
627
625
  user_type="ADMIN",
628
- persmission=[
626
+ persmissions=[
629
627
  "READ"
630
628
  ],
631
629
  )
@@ -35,6 +35,7 @@ def main() -> FastAPI:
35
35
  .with_description("A shared tools for other services.")
36
36
  .with_version("0.1.0")
37
37
  .with_environment(Environment.PRODUCTION)
38
+ .with_default_exception_handlers()
38
39
  )
39
40
 
40
41
  app = builder.build()
@@ -115,9 +116,7 @@ class UserController(ControllerBase):
115
116
  def main() -> FastAPI:
116
117
  ...
117
118
 
118
- builder.with_controllers([
119
- UserController
120
- ])
119
+ builder.with_controllers(UserController)
121
120
 
122
121
  ...
123
122
  ```
@@ -145,9 +144,7 @@ async def login(
145
144
  def main() -> FastAPI:
146
145
  ...
147
146
 
148
- builder.with_routers([
149
- router
150
- ])
147
+ builder.with_routers(router)
151
148
 
152
149
  ...
153
150
  ```
@@ -254,6 +251,7 @@ def main() -> FastAPI:
254
251
  container=builder.container,
255
252
  )
256
253
 
254
+ rabbitmq.init_default_exception_handlers()
257
255
  rabbitmq.include_listener(UserConsumer)
258
256
  builder.add_singleton(
259
257
  service=RabbitMqManager,
@@ -277,7 +275,7 @@ async def store_user(
277
275
  publisher = rabbitmq.publisher("UserQueue")
278
276
 
279
277
  await publisher.publish(user)
280
- # await publisher.publish_with_arguments(user)
278
+ # await publisher.publish_as_arguments(user)
281
279
  ```
282
280
 
283
281
  ### RPC client
@@ -609,7 +607,7 @@ class UserController(ControllerBase):
609
607
  UserInfo,
610
608
  Authorization(
611
609
  user_type="ADMIN",
612
- persmission=[
610
+ persmissions=[
613
611
  "READ"
614
612
  ],
615
613
  )
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "qena-shared-lib"
3
- version = "0.1.13"
3
+ version = "0.1.15"
4
4
  description = "A shared tools for other services"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,6 +1,5 @@
1
1
  from functools import lru_cache
2
2
  from logging import (
3
- INFO,
4
3
  Formatter,
5
4
  Handler,
6
5
  Logger,
@@ -18,11 +17,6 @@ ROOT_LOGGER_NAME = environ.get("LOGGER_NAME") or "qena_shared_lib"
18
17
 
19
18
 
20
19
  class LoggerProvider:
21
- def __init__(self) -> None:
22
- logger = self.get_logger()
23
-
24
- logger.setLevel(INFO)
25
-
26
20
  @lru_cache
27
21
  @staticmethod
28
22
  def default() -> "LoggerProvider":
@@ -10,10 +10,6 @@ from random import uniform
10
10
  from typing import (
11
11
  Any,
12
12
  Awaitable,
13
- Callable,
14
- Concatenate,
15
- Generic,
16
- ParamSpec,
17
13
  TypeVar,
18
14
  cast,
19
15
  )
@@ -55,13 +51,6 @@ __all__ = [
55
51
  ]
56
52
 
57
53
 
58
- E = TypeVar("E", bound=BaseException)
59
- P = ParamSpec("P")
60
- SyncExceptionHandler = Callable[Concatenate[ListenerContext, E, P], None]
61
- AsyncExcpetionHandler = Callable[
62
- Concatenate[ListenerContext, E, P], Awaitable[None]
63
- ]
64
- ExceptionHandler = SyncExceptionHandler[E, P] | AsyncExcpetionHandler[E, P]
65
54
  R = TypeVar("R")
66
55
 
67
56
 
@@ -75,7 +64,7 @@ class AbstractRabbitMQService(ABC):
75
64
  raise NotImplementedError()
76
65
 
77
66
 
78
- class RabbitMqManager(Generic[E, P], AsyncEventLoopMixin):
67
+ class RabbitMqManager(AsyncEventLoopMixin):
79
68
  RABBITMQ_CONNECTION_STATE = PrometheusEnum(
80
69
  name="rabbitmq_connection_state",
81
70
  documentation="Babbitmq connection state",
@@ -462,10 +451,12 @@ class RabbitMqManager(Generic[E, P], AsyncEventLoopMixin):
462
451
  ).add_done_callback(self._listener_and_service_config_and_init_done)
463
452
 
464
453
  def _configure_listeners(self) -> list[Awaitable[Any]]:
465
- try:
466
- assert self._connection is not None
454
+ assert self._connection is not None
467
455
 
468
- return [
456
+ listeners_configured_coroutines: list[Awaitable[Any]] = []
457
+
458
+ try:
459
+ listeners_configured_coroutines.extend(
469
460
  listener.configure(
470
461
  connection=self._connection,
471
462
  channel_pool=self._channel_pool,
@@ -475,28 +466,36 @@ class RabbitMqManager(Generic[E, P], AsyncEventLoopMixin):
475
466
  global_retry_policy=self._listener_global_retry_policy,
476
467
  )
477
468
  for listener in self._listeners
478
- ]
469
+ )
479
470
  except Exception as e:
480
471
  listener_configuration_error_future = self.loop.create_future()
481
472
 
482
473
  listener_configuration_error_future.set_exception(e)
474
+ listeners_configured_coroutines.append(
475
+ listener_configuration_error_future
476
+ )
483
477
 
484
- return [listener_configuration_error_future]
478
+ return listeners_configured_coroutines
485
479
 
486
480
  def _initialize_services(self) -> list[Future[Any]]:
487
481
  assert self._connection is not None
488
482
 
483
+ service_initialization_futures: list[Future[Any]] = []
484
+
489
485
  try:
490
- return [
486
+ service_initialization_futures.extend(
491
487
  service.initialize(self._connection, self._channel_pool)
492
488
  for service in self._services
493
- ]
489
+ )
494
490
  except Exception as e:
495
491
  service_initialization_error_future = self.loop.create_future()
496
492
 
497
493
  service_initialization_error_future.set_exception(e)
494
+ service_initialization_futures.append(
495
+ service_initialization_error_future
496
+ )
498
497
 
499
- return [service_initialization_error_future]
498
+ return service_initialization_futures
500
499
 
501
500
  def _listener_and_service_config_and_init_done(
502
501
  self, future: Future[list[Any]]
@@ -532,7 +531,7 @@ class RabbitMqManager(Generic[E, P], AsyncEventLoopMixin):
532
531
  service_count = len(self._services)
533
532
 
534
533
  self._logger.info(
535
- "connect to rabbitmq, `%s:%s%s` with `%d` %s and `%d` %s.",
534
+ "connected to rabbitmq, `%s:%s%s` with `%d` %s and `%d` %s.",
536
535
  params.host,
537
536
  params.port,
538
537
  params.virtual_host,
@@ -1,4 +1,5 @@
1
1
  from asyncio import AbstractEventLoop, get_running_loop
2
+ from typing import Generator
2
3
 
3
4
  from pydantic import TypeAdapter
4
5
 
@@ -32,3 +33,12 @@ class TypeAdapterCache:
32
33
  cls.cache_annotation(annotation)
33
34
 
34
35
  return cls._cache[annotation]
36
+
37
+
38
+ class YieldOnce:
39
+ def __await__(self) -> Generator[None, None, None]:
40
+ return (yield)
41
+
42
+
43
+ def yield_now() -> YieldOnce:
44
+ return YieldOnce()
@@ -1,55 +0,0 @@
1
- # This file was autogenerated by uv via the following command:
2
- # uv export --no-dev --no-hashes --format requirements-txt
3
- -e .
4
- annotated-types==0.7.0
5
- anyio==4.6.0
6
- bcrypt==4.2.1
7
- certifi==2024.8.30
8
- cffi==1.17.1 ; platform_python_implementation != 'PyPy'
9
- click==8.1.8
10
- colorama==0.4.6 ; sys_platform == 'win32'
11
- cronsim==2.6
12
- cryptography==44.0.0
13
- dnspython==2.7.0
14
- email-validator==2.2.0
15
- exceptiongroup==1.2.2 ; python_full_version < '3.11'
16
- fastapi==0.115.6
17
- fastapi-cli==0.0.7
18
- h11==0.14.0
19
- httpcore==1.0.6
20
- httptools==0.6.4
21
- httpx==0.27.2
22
- idna==3.10
23
- itsdangerous==2.2.0
24
- jinja2==3.1.5
25
- jwt==1.3.1
26
- markdown-it-py==3.0.0
27
- markupsafe==3.0.2
28
- mdurl==0.1.2
29
- orjson==3.10.12
30
- passlib==1.7.4
31
- pika==1.3.2
32
- prometheus-client==0.21.1
33
- prometheus-fastapi-instrumentator==7.0.2
34
- punq==0.7.0
35
- pycparser==2.22 ; platform_python_implementation != 'PyPy'
36
- pydantic==2.10.3
37
- pydantic-core==2.27.1
38
- pydantic-extra-types==2.10.1
39
- pydantic-settings==2.7.0
40
- pygments==2.18.0
41
- python-dotenv==1.0.1
42
- python-multipart==0.0.20
43
- pyyaml==6.0.2
44
- rich==13.9.4
45
- rich-toolkit==0.12.0
46
- shellingham==1.5.4
47
- sniffio==1.3.1
48
- starlette==0.41.3
49
- typer==0.15.1
50
- typing-extensions==4.12.2
51
- ujson==5.10.0
52
- uvicorn==0.34.0
53
- uvloop==0.21.0 ; platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32'
54
- watchfiles==1.0.3
55
- websockets==14.1