nlbone 0.7.9__py3-none-any.whl → 0.7.11__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.
- nlbone/adapters/db/postgres/uow.py +3 -1
- nlbone/interfaces/api/schema/base_response_model.py +1 -1
- nlbone/utils/cache.py +57 -17
- {nlbone-0.7.9.dist-info → nlbone-0.7.11.dist-info}/METADATA +1 -1
- {nlbone-0.7.9.dist-info → nlbone-0.7.11.dist-info}/RECORD +8 -8
- {nlbone-0.7.9.dist-info → nlbone-0.7.11.dist-info}/WHEEL +0 -0
- {nlbone-0.7.9.dist-info → nlbone-0.7.11.dist-info}/entry_points.txt +0 -0
- {nlbone-0.7.9.dist-info → nlbone-0.7.11.dist-info}/licenses/LICENSE +0 -0
|
@@ -53,7 +53,9 @@ class SqlAlchemyUnitOfWork(UnitOfWork):
|
|
|
53
53
|
def collect_new_events(self) -> Iterator[DomainEvent]:
|
|
54
54
|
for name, type_ in self.__annotations__.items():
|
|
55
55
|
if isinstance(type_, type) and issubclass(type_, Repository):
|
|
56
|
-
repo = getattr(self, name)
|
|
56
|
+
repo = getattr(self, name, None)
|
|
57
|
+
if not repo:
|
|
58
|
+
continue
|
|
57
59
|
for entity in repo.seen:
|
|
58
60
|
for event in entity.events:
|
|
59
61
|
yield event
|
nlbone/utils/cache.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import inspect
|
|
3
3
|
import json
|
|
4
|
-
from typing import Any, Callable, Iterable, Optional
|
|
4
|
+
from typing import Any, Callable, Iterable, Optional, Mapping
|
|
5
5
|
|
|
6
6
|
from makefun import wraps as mf_wraps
|
|
7
7
|
|
|
8
|
+
from nlbone.interfaces.api.additional_filed import AdditionalFieldsRequest
|
|
9
|
+
from nlbone.interfaces.api.pagination import PaginateRequest
|
|
8
10
|
from nlbone.utils.cache_registry import get_cache
|
|
9
11
|
|
|
10
12
|
try:
|
|
@@ -25,11 +27,42 @@ def _bind(func: Callable, args, kwargs):
|
|
|
25
27
|
return bound
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
PRIMITIVES = (str, int, float, bool, type(None))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def to_jsonable(obj):
|
|
34
|
+
if isinstance(obj, PRIMITIVES):
|
|
35
|
+
return obj
|
|
36
|
+
|
|
37
|
+
if isinstance(obj, dict):
|
|
38
|
+
return {str(k): to_jsonable(v) for k, v in obj.items()}
|
|
39
|
+
|
|
40
|
+
if isinstance(obj, (list, tuple, set)):
|
|
41
|
+
return [to_jsonable(v) for v in obj]
|
|
42
|
+
|
|
43
|
+
if isinstance(obj, PaginateRequest):
|
|
44
|
+
return {
|
|
45
|
+
"limit": obj.limit,
|
|
46
|
+
"offset": obj.offset,
|
|
47
|
+
"sort": obj.sort,
|
|
48
|
+
"filters": obj.filters,
|
|
49
|
+
"include_ids": obj.include_ids,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if isinstance(obj, AdditionalFieldsRequest):
|
|
53
|
+
return {
|
|
54
|
+
"fields": obj.fields,
|
|
55
|
+
"bundles": obj.bundles,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return f"<{obj.__class__.__name__}>"
|
|
59
|
+
|
|
60
|
+
|
|
28
61
|
def _key_from_template(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
62
|
+
tpl: Optional[str],
|
|
63
|
+
func: Callable,
|
|
64
|
+
args,
|
|
65
|
+
kwargs,
|
|
33
66
|
) -> str:
|
|
34
67
|
"""Format key template with bound arguments or build a stable default."""
|
|
35
68
|
bound = _bind(func, args, kwargs)
|
|
@@ -37,15 +70,22 @@ def _key_from_template(
|
|
|
37
70
|
return tpl.format(**bound.arguments)
|
|
38
71
|
|
|
39
72
|
# Default stable key: module:qualname:sha of args
|
|
40
|
-
|
|
73
|
+
|
|
74
|
+
clean_args = to_jsonable(bound.arguments)
|
|
75
|
+
payload = json.dumps(clean_args, sort_keys=True)
|
|
76
|
+
|
|
77
|
+
payload = json.dumps(
|
|
78
|
+
payload,
|
|
79
|
+
sort_keys=True,
|
|
80
|
+
)
|
|
41
81
|
return f"{func.__module__}:{func.__qualname__}:{hash(payload)}"
|
|
42
82
|
|
|
43
83
|
|
|
44
84
|
def _format_tags(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
tag_tpls: Optional[Iterable[str]],
|
|
86
|
+
func: Callable,
|
|
87
|
+
args,
|
|
88
|
+
kwargs,
|
|
49
89
|
) -> list[str] | None:
|
|
50
90
|
if not tag_tpls:
|
|
51
91
|
return None
|
|
@@ -84,13 +124,13 @@ def _run_maybe_async(func: Callable, *args, **kwargs):
|
|
|
84
124
|
|
|
85
125
|
|
|
86
126
|
def cached(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
127
|
+
*,
|
|
128
|
+
ttl: int,
|
|
129
|
+
key: str | None = None,
|
|
130
|
+
tags: Iterable[str] | None = None,
|
|
131
|
+
serializer: Callable[[Any], bytes] = default_serialize,
|
|
132
|
+
deserializer: Callable[[bytes], Any] = default_deserialize,
|
|
133
|
+
cache_resolver: Optional[Callable[[], Any]] = None,
|
|
94
134
|
):
|
|
95
135
|
"""
|
|
96
136
|
Framework-agnostic caching for SYNC or ASYNC callables.
|
|
@@ -21,7 +21,7 @@ nlbone/adapters/db/postgres/query_builder.py,sha256=Qv_2oZ5OxZwtN3Ts-jaAX_8sLBzb
|
|
|
21
21
|
nlbone/adapters/db/postgres/repository.py,sha256=n01TAzdKd-UbOhirE6KMosuvRdJG2l1cszwVHjTM-Ks,10345
|
|
22
22
|
nlbone/adapters/db/postgres/schema.py,sha256=NlE7Rr8uXypsw4oWkdZhZwcIBHQEPIpoHLxcUo98i6s,1039
|
|
23
23
|
nlbone/adapters/db/postgres/types.py,sha256=OXra45PL8Umrqj6Pul_8ZlYRGIWQE36jvBXxui_u6hs,600
|
|
24
|
-
nlbone/adapters/db/postgres/uow.py,sha256=
|
|
24
|
+
nlbone/adapters/db/postgres/uow.py,sha256=I4RVeIbGEVhVGcuzhdEUJuX11RhEHTn0egrkCbcsz24,3852
|
|
25
25
|
nlbone/adapters/db/redis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
nlbone/adapters/db/redis/client.py,sha256=5SUnwP2-GrueSFimUbiqDvrQsumvIE2aeozk8l-vOfQ,466
|
|
27
27
|
nlbone/adapters/http_clients/__init__.py,sha256=w-Yr9CLuXMU71N0Ada5HbvP1DB53wqeP6B-i5rALlTo,150
|
|
@@ -88,7 +88,7 @@ nlbone/interfaces/api/pagination/__init__.py,sha256=pA1uC4rK6eqDI5IkLVxmgO2B6lEx
|
|
|
88
88
|
nlbone/interfaces/api/pagination/offset_base.py,sha256=65UgQZ70IlWUbP9Usd--IxVYW_V0hQLoyXHVffnLFZ0,3940
|
|
89
89
|
nlbone/interfaces/api/schema/__init__.py,sha256=LAqgynfupeqOQ6u0I5ucrcYnojRMZUg9yW8IjKSQTNI,119
|
|
90
90
|
nlbone/interfaces/api/schema/adaptive_schema.py,sha256=bdWBNpP2NfOJ_in4btXn0lrZOK70x-OqfmZ-NpIJdoQ,3347
|
|
91
|
-
nlbone/interfaces/api/schema/base_response_model.py,sha256=
|
|
91
|
+
nlbone/interfaces/api/schema/base_response_model.py,sha256=IdAw01ScbqWcyKLwn0LLY5C8wPq2188BkHDUEJw-4lw,775
|
|
92
92
|
nlbone/interfaces/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
93
|
nlbone/interfaces/cli/crypto.py,sha256=lh2uUbSYKT6XxAt9uP1-VksopqAgdxiSKoKgXwXB0aE,692
|
|
94
94
|
nlbone/interfaces/cli/init_db.py,sha256=Hk3aZ8w9KdfgQfDWaOnIgNEAegn2uNggkkSgDXQLgyc,1791
|
|
@@ -98,7 +98,7 @@ nlbone/interfaces/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
98
98
|
nlbone/interfaces/jobs/dispatch_outbox.py,sha256=yLZSC3nvkgxT2LL4Pq_DYzCyf_tZB-FknrjjgN89GFg,809
|
|
99
99
|
nlbone/interfaces/jobs/sync_tokens.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
100
100
|
nlbone/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
-
nlbone/utils/cache.py,sha256=
|
|
101
|
+
nlbone/utils/cache.py,sha256=HyoVIJ9WDSQeSROgCoxY96-NUTajl3A1L2fhxRa1DN0,6988
|
|
102
102
|
nlbone/utils/cache_keys.py,sha256=Y2YSellHTbUOcoaNbl1jaD4r485VU_e4KXsfBWhYTBo,1075
|
|
103
103
|
nlbone/utils/cache_registry.py,sha256=w28sEfUQZAhzCCqVH5TflWQY3nyDXyEcFWt8hkuHRHw,823
|
|
104
104
|
nlbone/utils/context.py,sha256=MmclJ24BG2uvSTg1IK7J-Da9BhVFDQ5ag4Ggs2FF1_w,1600
|
|
@@ -107,8 +107,8 @@ nlbone/utils/http.py,sha256=MPDEyaC16AKsL0YH6sWCPp8NC2TgzEHpWERYK5HcaYQ,1001
|
|
|
107
107
|
nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYkS_E,732
|
|
108
108
|
nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
|
|
109
109
|
nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
|
|
110
|
-
nlbone-0.7.
|
|
111
|
-
nlbone-0.7.
|
|
112
|
-
nlbone-0.7.
|
|
113
|
-
nlbone-0.7.
|
|
114
|
-
nlbone-0.7.
|
|
110
|
+
nlbone-0.7.11.dist-info/METADATA,sha256=xaLQVPgxrifFVdB1r-VlgQicLswzLwPBiCubMxTZimo,2295
|
|
111
|
+
nlbone-0.7.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
112
|
+
nlbone-0.7.11.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
|
|
113
|
+
nlbone-0.7.11.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
114
|
+
nlbone-0.7.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|