qena-shared-lib 0.1.5__tar.gz → 0.1.6__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.5 → qena_shared_lib-0.1.6}/PKG-INFO +1 -1
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/pyproject.toml +1 -1
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/exception_handlers.py +16 -3
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_listener.py +1 -2
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_rpc_client.py +1 -2
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/utils.py +18 -1
- qena_shared_lib-0.1.5/src/qena_shared_lib/rabbitmq/_utils.py +0 -18
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/.gitignore +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/.pre-commit-config.yaml +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/README.md +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/requirements.txt +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/__init__.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/application.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/background.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/dependencies/__init__.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/dependencies/http.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/dependencies/miscellaneous.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/exceptions.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/http.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logging.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logstash/__init__.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logstash/_base.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logstash/_http_sender.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logstash/_tcp_sender.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/py.typed +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/__init__.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_base.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_channel.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_exception_handlers.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_exceptions.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_pool.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_publisher.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/scheduler.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/security.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/conftest.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_application.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_background.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_dependencies.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_logstash.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_rabbitmq.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_scheduler.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/tests/test_security.py +0 -0
- {qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/uv.lock +0 -0
@@ -1,9 +1,10 @@
|
|
1
|
+
from collections.abc import Iterable
|
1
2
|
from typing import Any
|
2
3
|
|
3
4
|
from fastapi import Request, Response, status
|
4
|
-
from fastapi.encoders import jsonable_encoder
|
5
5
|
from fastapi.exceptions import RequestValidationError
|
6
6
|
from fastapi.responses import JSONResponse
|
7
|
+
from pydantic_core import to_jsonable_python
|
7
8
|
|
8
9
|
from .dependencies.http import get_service
|
9
10
|
from .exceptions import ServiceException, Severity
|
@@ -93,7 +94,19 @@ def handle_service_exception(
|
|
93
94
|
content["correctiveAction"] = exception.corrective_action
|
94
95
|
|
95
96
|
if exception.body is not None:
|
96
|
-
|
97
|
+
extra_body = to_jsonable_python(exception.body)
|
98
|
+
is_updated = False
|
99
|
+
|
100
|
+
try:
|
101
|
+
if isinstance(extra_body, Iterable):
|
102
|
+
content.update(extra_body)
|
103
|
+
|
104
|
+
is_updated = True
|
105
|
+
except:
|
106
|
+
pass
|
107
|
+
|
108
|
+
if not is_updated:
|
109
|
+
content["data"] = extra_body
|
97
110
|
|
98
111
|
return JSONResponse(
|
99
112
|
content=content,
|
@@ -117,7 +130,7 @@ def handle_request_validation_error(
|
|
117
130
|
"severity": Severity.MEDIUM.name,
|
118
131
|
"message": message,
|
119
132
|
"code": 100,
|
120
|
-
"detail":
|
133
|
+
"detail": to_jsonable_python(error.errors()),
|
121
134
|
},
|
122
135
|
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
123
136
|
)
|
@@ -21,11 +21,10 @@ from pydantic_core import from_json, to_json
|
|
21
21
|
from ..dependencies.miscellaneous import validate_annotation
|
22
22
|
from ..logging import LoggerProvider
|
23
23
|
from ..logstash import BaseLogstashSender
|
24
|
-
from ..utils import AsyncEventLoopMixin
|
24
|
+
from ..utils import AsyncEventLoopMixin, TypeAdapterCache
|
25
25
|
from ._channel import BaseChannel
|
26
26
|
from ._exceptions import RabbitMQException
|
27
27
|
from ._pool import ChannelPool
|
28
|
-
from ._utils import TypeAdapterCache
|
29
28
|
|
30
29
|
__all__ = [
|
31
30
|
"BackoffRetryDelay",
|
@@ -13,10 +13,9 @@ from prometheus_client import Counter, Summary
|
|
13
13
|
from pydantic_core import from_json, to_json
|
14
14
|
|
15
15
|
from ..logging import LoggerProvider
|
16
|
-
from ..utils import AsyncEventLoopMixin
|
16
|
+
from ..utils import AsyncEventLoopMixin, TypeAdapterCache
|
17
17
|
from ._exceptions import RabbitMQException
|
18
18
|
from ._pool import ChannelPool
|
19
|
-
from ._utils import TypeAdapterCache
|
20
19
|
|
21
20
|
__all__ = ["RpcClient"]
|
22
21
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
from asyncio import AbstractEventLoop, get_running_loop
|
2
2
|
|
3
|
-
|
3
|
+
from pydantic import TypeAdapter
|
4
|
+
|
5
|
+
__all__ = ["AsyncEventLoopMixin", "TypeAdapterCache"]
|
4
6
|
|
5
7
|
ABSTRACT_EVENT_LOOP_ATTRIBUTE = "__abstract_event_loop__"
|
6
8
|
|
@@ -26,3 +28,18 @@ class AsyncEventLoopMixin:
|
|
26
28
|
setattr(self, ABSTRACT_EVENT_LOOP_ATTRIBUTE, current_running_loop)
|
27
29
|
|
28
30
|
return getattr(self, ABSTRACT_EVENT_LOOP_ATTRIBUTE)
|
31
|
+
|
32
|
+
|
33
|
+
class TypeAdapterCache:
|
34
|
+
_cache = {}
|
35
|
+
|
36
|
+
@classmethod
|
37
|
+
def cache_annotation(cls, annotation: type):
|
38
|
+
if annotation not in cls._cache:
|
39
|
+
cls._cache[annotation] = TypeAdapter(annotation)
|
40
|
+
|
41
|
+
@classmethod
|
42
|
+
def get_type_adapter(cls, annotation: type) -> TypeAdapter:
|
43
|
+
cls.cache_annotation(annotation)
|
44
|
+
|
45
|
+
return cls._cache[annotation]
|
@@ -1,18 +0,0 @@
|
|
1
|
-
from pydantic import TypeAdapter
|
2
|
-
|
3
|
-
__all__ = ["TypeAdapterCache"]
|
4
|
-
|
5
|
-
|
6
|
-
class TypeAdapterCache:
|
7
|
-
_cache = {}
|
8
|
-
|
9
|
-
@classmethod
|
10
|
-
def cache_annotation(cls, annotation: type):
|
11
|
-
if annotation not in cls._cache:
|
12
|
-
cls._cache[annotation] = TypeAdapter(annotation)
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
def get_type_adapter(cls, annotation: type) -> TypeAdapter:
|
16
|
-
cls.cache_annotation(annotation)
|
17
|
-
|
18
|
-
return cls._cache[annotation]
|
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.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/dependencies/__init__.py
RENAMED
File without changes
|
File without changes
|
{qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/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
|
{qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/logstash/_http_sender.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{qena_shared_lib-0.1.5 → qena_shared_lib-0.1.6}/src/qena_shared_lib/rabbitmq/_exception_handlers.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
|