qena-shared-lib 0.1.14__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.
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/.pre-commit-config.yaml +8 -8
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/CHANGELOG.md +8 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/PKG-INFO +7 -9
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/README.md +6 -8
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/pyproject.toml +1 -1
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/logging.py +0 -6
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_base.py +19 -9
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/utils.py +10 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/.gitignore +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/__init__.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/application.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/background.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/__init__.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/http.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/miscellaneous.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/exception_handlers.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/exceptions.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/http.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/py.typed +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/__init__.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_channel.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_exception_handlers.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_listener.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_pool.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_publisher.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_rpc_client.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/__init__.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/_base.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/__init__.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_base.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_http_sender.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/logstash/_tcp_sender.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/scheduler.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/security.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/conftest.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_application.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_background.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_dependencies.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_logstash.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_rabbitmq.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_scheduler.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/test_security.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/tests/utils.py +0 -0
- {qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/uv.lock +0 -0
@@ -1,12 +1,12 @@
|
|
1
1
|
repos:
|
2
|
-
-
|
3
|
-
|
4
|
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
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,12 @@
|
|
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
|
+
|
3
10
|
## [0.1.14] - 2025-06-16
|
4
11
|
|
5
12
|
### Changed
|
@@ -30,6 +37,7 @@
|
|
30
37
|
- Added a re-export for rabbitmq channel pool (ChannelPool) class.
|
31
38
|
|
32
39
|
|
40
|
+
[0.1.15]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.14...v0.1.15
|
33
41
|
[0.1.14]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.13...v0.1.14
|
34
42
|
[0.1.13]: https://github.com/Qena-Digital-Lending/qena-shared-kernel/compare/v0.1.12...v0.1.13
|
35
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.
|
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.
|
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
|
-
|
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.
|
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
|
-
|
610
|
+
persmissions=[
|
613
611
|
"READ"
|
614
612
|
],
|
615
613
|
)
|
@@ -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":
|
@@ -451,10 +451,12 @@ class RabbitMqManager(AsyncEventLoopMixin):
|
|
451
451
|
).add_done_callback(self._listener_and_service_config_and_init_done)
|
452
452
|
|
453
453
|
def _configure_listeners(self) -> list[Awaitable[Any]]:
|
454
|
-
|
455
|
-
|
454
|
+
assert self._connection is not None
|
455
|
+
|
456
|
+
listeners_configured_coroutines: list[Awaitable[Any]] = []
|
456
457
|
|
457
|
-
|
458
|
+
try:
|
459
|
+
listeners_configured_coroutines.extend(
|
458
460
|
listener.configure(
|
459
461
|
connection=self._connection,
|
460
462
|
channel_pool=self._channel_pool,
|
@@ -464,28 +466,36 @@ class RabbitMqManager(AsyncEventLoopMixin):
|
|
464
466
|
global_retry_policy=self._listener_global_retry_policy,
|
465
467
|
)
|
466
468
|
for listener in self._listeners
|
467
|
-
|
469
|
+
)
|
468
470
|
except Exception as e:
|
469
471
|
listener_configuration_error_future = self.loop.create_future()
|
470
472
|
|
471
473
|
listener_configuration_error_future.set_exception(e)
|
474
|
+
listeners_configured_coroutines.append(
|
475
|
+
listener_configuration_error_future
|
476
|
+
)
|
472
477
|
|
473
|
-
|
478
|
+
return listeners_configured_coroutines
|
474
479
|
|
475
480
|
def _initialize_services(self) -> list[Future[Any]]:
|
476
481
|
assert self._connection is not None
|
477
482
|
|
483
|
+
service_initialization_futures: list[Future[Any]] = []
|
484
|
+
|
478
485
|
try:
|
479
|
-
|
486
|
+
service_initialization_futures.extend(
|
480
487
|
service.initialize(self._connection, self._channel_pool)
|
481
488
|
for service in self._services
|
482
|
-
|
489
|
+
)
|
483
490
|
except Exception as e:
|
484
491
|
service_initialization_error_future = self.loop.create_future()
|
485
492
|
|
486
493
|
service_initialization_error_future.set_exception(e)
|
494
|
+
service_initialization_futures.append(
|
495
|
+
service_initialization_error_future
|
496
|
+
)
|
487
497
|
|
488
|
-
|
498
|
+
return service_initialization_futures
|
489
499
|
|
490
500
|
def _listener_and_service_config_and_init_done(
|
491
501
|
self, future: Future[list[Any]]
|
@@ -521,7 +531,7 @@ class RabbitMqManager(AsyncEventLoopMixin):
|
|
521
531
|
service_count = len(self._services)
|
522
532
|
|
523
533
|
self._logger.info(
|
524
|
-
"
|
534
|
+
"connected to rabbitmq, `%s:%s%s` with `%d` %s and `%d` %s.",
|
525
535
|
params.host,
|
526
536
|
params.port,
|
527
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()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/__init__.py
RENAMED
File without changes
|
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/dependencies/miscellaneous.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_publisher.py
RENAMED
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/rabbitmq/_rpc_client.py
RENAMED
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/__init__.py
RENAMED
File without changes
|
{qena_shared_lib-0.1.14 → qena_shared_lib-0.1.15}/src/qena_shared_lib/remotelogging/_base.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|