qena-shared-lib 0.1.23__py3-none-any.whl → 0.1.24__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.
- qena_shared_lib/__init__.py +1 -1
- qena_shared_lib/eventbus.py +2 -3
- qena_shared_lib/exceptions.py +4 -4
- qena_shared_lib/http/_exception_handlers.py +1 -1
- qena_shared_lib/mongodb.py +28 -22
- {qena_shared_lib-0.1.23.dist-info → qena_shared_lib-0.1.24.dist-info}/METADATA +9 -9
- {qena_shared_lib-0.1.23.dist-info → qena_shared_lib-0.1.24.dist-info}/RECORD +8 -8
- {qena_shared_lib-0.1.23.dist-info → qena_shared_lib-0.1.24.dist-info}/WHEEL +0 -0
qena_shared_lib/__init__.py
CHANGED
qena_shared_lib/eventbus.py
CHANGED
|
@@ -10,13 +10,12 @@ from pika.frame import Method
|
|
|
10
10
|
from pika.spec import Basic, BasicProperties
|
|
11
11
|
from pydantic_core import to_json
|
|
12
12
|
|
|
13
|
-
from
|
|
13
|
+
from .alias import CamelCaseAliasedBaseModel
|
|
14
|
+
from .rabbitmq import (
|
|
14
15
|
AbstractRabbitMQService,
|
|
15
16
|
BaseChannel,
|
|
16
17
|
ChannelPool,
|
|
17
18
|
)
|
|
18
|
-
|
|
19
|
-
from .alias import CamelCaseAliasedBaseModel
|
|
20
19
|
from .remotelogging import BaseRemoteLogSender
|
|
21
20
|
from .utils import AsyncEventLoopMixin
|
|
22
21
|
|
qena_shared_lib/exceptions.py
CHANGED
|
@@ -258,11 +258,11 @@ class PreconditionFailed(ClientError):
|
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
class PayloadTooLarge(ClientError):
|
|
261
|
-
GENERAL_STATUS_CODE = status.
|
|
261
|
+
GENERAL_STATUS_CODE = status.HTTP_413_CONTENT_TOO_LARGE
|
|
262
262
|
|
|
263
263
|
|
|
264
264
|
class URITooLong(ClientError):
|
|
265
|
-
GENERAL_STATUS_CODE = status.
|
|
265
|
+
GENERAL_STATUS_CODE = status.HTTP_414_URI_TOO_LONG
|
|
266
266
|
|
|
267
267
|
|
|
268
268
|
class UnsupportedMediaType(ClientError):
|
|
@@ -270,7 +270,7 @@ class UnsupportedMediaType(ClientError):
|
|
|
270
270
|
|
|
271
271
|
|
|
272
272
|
class RangeNotSatisfiable(ClientError):
|
|
273
|
-
GENERAL_STATUS_CODE = status.
|
|
273
|
+
GENERAL_STATUS_CODE = status.HTTP_416_RANGE_NOT_SATISFIABLE
|
|
274
274
|
|
|
275
275
|
|
|
276
276
|
class ExpectationFailed(ClientError):
|
|
@@ -286,7 +286,7 @@ class MisdirectedRequest(ClientError):
|
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
class UnprocessableEntity(ClientError):
|
|
289
|
-
GENERAL_STATUS_CODE = status.
|
|
289
|
+
GENERAL_STATUS_CODE = status.HTTP_422_UNPROCESSABLE_CONTENT
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
class Locked(ClientError):
|
|
@@ -154,7 +154,7 @@ class RequestValidationErrorHandler(AbstractHttpExceptionHandler):
|
|
|
154
154
|
"code": 100,
|
|
155
155
|
"detail": to_jsonable_python(error.errors()),
|
|
156
156
|
},
|
|
157
|
-
status_code=status.
|
|
157
|
+
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
|
158
158
|
)
|
|
159
159
|
|
|
160
160
|
|
qena_shared_lib/mongodb.py
CHANGED
|
@@ -87,9 +87,11 @@ class MongoDBManager:
|
|
|
87
87
|
|
|
88
88
|
@asynccontextmanager
|
|
89
89
|
async def transactional(self) -> AsyncGenerator[AsyncClientSession, None]:
|
|
90
|
-
async with
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
async with (
|
|
91
|
+
self.client.start_session() as session,
|
|
92
|
+
await session.start_transaction(),
|
|
93
|
+
):
|
|
94
|
+
yield session
|
|
93
95
|
|
|
94
96
|
def __getitem__(self, document: type["Document"]) -> AsyncCollection:
|
|
95
97
|
return self._db.get_collection(document.get_collection_name())
|
|
@@ -257,6 +259,7 @@ class RepositoryBase(Generic[T]):
|
|
|
257
259
|
self._db = db
|
|
258
260
|
self._session = None
|
|
259
261
|
self._document_type = None
|
|
262
|
+
self._collection = None
|
|
260
263
|
|
|
261
264
|
@property
|
|
262
265
|
def db(self) -> MongoDBManager:
|
|
@@ -264,7 +267,10 @@ class RepositoryBase(Generic[T]):
|
|
|
264
267
|
|
|
265
268
|
@property
|
|
266
269
|
def collection(self) -> AsyncCollection:
|
|
267
|
-
|
|
270
|
+
if self._collection is None:
|
|
271
|
+
self._collection = self._db[self.document_type]
|
|
272
|
+
|
|
273
|
+
return self._collection
|
|
268
274
|
|
|
269
275
|
@property
|
|
270
276
|
def session(self) -> AsyncClientSession | None:
|
|
@@ -568,25 +574,25 @@ class RepositoryBase(Generic[T]):
|
|
|
568
574
|
limit: int | None = None,
|
|
569
575
|
session: AsyncClientSession | None = None,
|
|
570
576
|
) -> int:
|
|
571
|
-
if filter is
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
options["skip"] = skip
|
|
576
|
-
|
|
577
|
-
if limit is not None and limit > 0:
|
|
578
|
-
options["limit"] = limit
|
|
579
|
-
|
|
580
|
-
return cast(
|
|
581
|
-
int,
|
|
582
|
-
await self.collection.count_documents(
|
|
583
|
-
filter=filter or {},
|
|
584
|
-
**options,
|
|
585
|
-
session=session or self.session,
|
|
586
|
-
),
|
|
587
|
-
)
|
|
577
|
+
if filter is None and skip is None and limit is None:
|
|
578
|
+
return cast(int, await self.collection.estimated_document_count())
|
|
579
|
+
|
|
580
|
+
options = {}
|
|
588
581
|
|
|
589
|
-
|
|
582
|
+
if skip is not None:
|
|
583
|
+
options["skip"] = skip
|
|
584
|
+
|
|
585
|
+
if limit is not None and limit > 0:
|
|
586
|
+
options["limit"] = limit
|
|
587
|
+
|
|
588
|
+
return cast(
|
|
589
|
+
int,
|
|
590
|
+
await self.collection.count_documents(
|
|
591
|
+
filter=filter or {},
|
|
592
|
+
**options,
|
|
593
|
+
session=session or self.session,
|
|
594
|
+
),
|
|
595
|
+
)
|
|
590
596
|
|
|
591
597
|
@overload
|
|
592
598
|
def aggregate(
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: qena-shared-lib
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.24
|
|
4
4
|
Summary: A shared tools for other services
|
|
5
|
-
Requires-Dist: fastapi[all]==0.
|
|
6
|
-
Requires-Dist: prometheus-client==0.
|
|
5
|
+
Requires-Dist: fastapi[all]==0.127.1
|
|
6
|
+
Requires-Dist: prometheus-client==0.22.1
|
|
7
7
|
Requires-Dist: prometheus-fastapi-instrumentator==7.0.2
|
|
8
8
|
Requires-Dist: punq==0.7.0
|
|
9
|
-
Requires-Dist: pydantic-core==2.
|
|
10
|
-
Requires-Dist: pydantic==2.10
|
|
11
|
-
Requires-Dist: starlette==0.
|
|
12
|
-
Requires-Dist: typing-extensions==4.
|
|
9
|
+
Requires-Dist: pydantic-core==2.33.2
|
|
10
|
+
Requires-Dist: pydantic==2.11.10
|
|
11
|
+
Requires-Dist: starlette==0.49.3
|
|
12
|
+
Requires-Dist: typing-extensions==4.14.1
|
|
13
13
|
Requires-Dist: aiokafka==0.12.0 ; extra == 'all'
|
|
14
14
|
Requires-Dist: cronsim==2.6 ; extra == 'all'
|
|
15
15
|
Requires-Dist: jwt==1.3.1 ; extra == 'all'
|
|
16
16
|
Requires-Dist: passlib[bcrypt]==1.7.4 ; extra == 'all'
|
|
17
17
|
Requires-Dist: pika==1.3.2 ; extra == 'all'
|
|
18
|
-
Requires-Dist: pymongo==4.15.
|
|
18
|
+
Requires-Dist: pymongo==4.15.5 ; extra == 'all'
|
|
19
19
|
Requires-Dist: redis==7.1.0 ; extra == 'all'
|
|
20
20
|
Requires-Dist: aiokafka==0.12.0 ; extra == 'kafka'
|
|
21
|
-
Requires-Dist: pymongo==4.15.
|
|
21
|
+
Requires-Dist: pymongo==4.15.5 ; extra == 'mongodb'
|
|
22
22
|
Requires-Dist: pika==1.3.2 ; extra == 'rabbitmq'
|
|
23
23
|
Requires-Dist: redis==7.1.0 ; extra == 'redis'
|
|
24
24
|
Requires-Dist: cronsim==2.6 ; extra == 'scheduler'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
qena_shared_lib/__init__.py,sha256=
|
|
1
|
+
qena_shared_lib/__init__.py,sha256=aJ7d-EF9UBmib4ebR8NMve5UwEzt9WXHf-7yvpAXbXM,661
|
|
2
2
|
qena_shared_lib/alias.py,sha256=y0qXPNR6CHWYHaci9JgMbnV5x18PHkaTZy03vnpUpXQ,645
|
|
3
3
|
qena_shared_lib/application.py,sha256=0pvuy5PxH5fw5FptTI4ksUxNAh-hzr_d5beAMDiBzi8,7117
|
|
4
4
|
qena_shared_lib/background.py,sha256=SCZhZOwWgv5T0X4tMB_aTecKlMdT12bzqpbA4qoZQPA,3473
|
|
@@ -7,12 +7,12 @@ qena_shared_lib/dependencies/__init__.py,sha256=W12RgJbhqZ9GiSV1nLlHmpwPzvQv8t7f
|
|
|
7
7
|
qena_shared_lib/dependencies/http.py,sha256=IBsMnRr8Jh8ixf2IcU6n1aYRMazI3fF9GLZxHM2dsXk,1492
|
|
8
8
|
qena_shared_lib/dependencies/miscellaneous.py,sha256=iGwAjatXb_JVSF13n1vdTRAgSKv19VtHo9ZbjjbkIco,753
|
|
9
9
|
qena_shared_lib/enums.py,sha256=qYOZUD8Or0O1uGoNRShMp-SzmkXDQ31djMVTG_yGxL4,107
|
|
10
|
-
qena_shared_lib/eventbus.py,sha256=
|
|
10
|
+
qena_shared_lib/eventbus.py,sha256=ocpVjywuV5ge41_yEq8Qk_nTEfo0jP3bUf2h6SLiWy8,11485
|
|
11
11
|
qena_shared_lib/exception_handling.py,sha256=oiPVaxD74y-dbB8hJsncPNd-Fphot60Q60tZQTbCZ50,13392
|
|
12
|
-
qena_shared_lib/exceptions.py,sha256=
|
|
12
|
+
qena_shared_lib/exceptions.py,sha256=l0HxWUYA0b338klq5CnGVmE-ZozDruPmkAOAJLXAmY0,14543
|
|
13
13
|
qena_shared_lib/http/__init__.py,sha256=F6CqzPsRx55fa5ozRkk2lSNJu28KPw9uI8zQwoo4lVU,2055
|
|
14
14
|
qena_shared_lib/http/_base.py,sha256=5jPAjiDmJIxjtMdhxNHpcTM_xbXC5eBMvy3U0tpB25Q,25199
|
|
15
|
-
qena_shared_lib/http/_exception_handlers.py,sha256
|
|
15
|
+
qena_shared_lib/http/_exception_handlers.py,sha256=my9tyzvT9V9VElcgipcrhPNWd3gEEpK_JKOUpIdN6ko,5944
|
|
16
16
|
qena_shared_lib/http/_request.py,sha256=kppCnS5zZfvKl-hNO6ysqkVdtoXshFp6Ue_0O5apqXQ,426
|
|
17
17
|
qena_shared_lib/http/_response.py,sha256=sUd2ggu6IeKtNhoYAr-xZmEn40HLq5vLHpRcV7mZFnk,432
|
|
18
18
|
qena_shared_lib/kafka/__init__.py,sha256=59aii_0Is8cwEVQlK4w9Jk3YrOqojTa6ReJO0SBedog,392
|
|
@@ -21,7 +21,7 @@ qena_shared_lib/kafka/_consumer.py,sha256=aEOtAqMhFPIMYbKK_BMDwR2rd_eaDzBJ6xR3Ud
|
|
|
21
21
|
qena_shared_lib/kafka/_exception_handlers.py,sha256=D7Xh5eSpSkumQKvPfBmVB_E6vQxD58y41bFpP5Jzhqk,4084
|
|
22
22
|
qena_shared_lib/kafka/_producer.py,sha256=QtYfKzNtxeIT1EtGpS-tvFC342oPoleF1AOl20LfNXs,3941
|
|
23
23
|
qena_shared_lib/logging.py,sha256=HZiqbXpmJsAI7hheAaQ9EA8uj9yU0pMVCg64d_V0wzA,1748
|
|
24
|
-
qena_shared_lib/mongodb.py,sha256=
|
|
24
|
+
qena_shared_lib/mongodb.py,sha256=7-NBQKOm75Ahu7Z28x_jpLsEjq1IkYzoQtJElhrNRHA,17787
|
|
25
25
|
qena_shared_lib/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
qena_shared_lib/rabbitmq/__init__.py,sha256=g15fP9XQ1CHFBXZmeAxQcsppQ0Nx62gJ4VOK8nzW7T4,1254
|
|
27
27
|
qena_shared_lib/rabbitmq/_base.py,sha256=pKJL0PNrhUOXw4XUJ1iZsuCPVY3ykvO8ebIfeX9HwXo,21502
|
|
@@ -45,6 +45,6 @@ qena_shared_lib/scheduler.py,sha256=Spp5PnpFJ0U4aLeFCNmje9zUA4zwkL-b7X8SSGkGssM,
|
|
|
45
45
|
qena_shared_lib/security.py,sha256=RAXBkfhytJl-2SOXYQTJMnUb789-8DNZKRjRtpod16Y,6372
|
|
46
46
|
qena_shared_lib/sync.py,sha256=79aGGWGYg_oGY9jTav1kghD8BSRY-_oNYdx3tuExr20,2541
|
|
47
47
|
qena_shared_lib/utils.py,sha256=crD8NJD1Se7ZHPCaQBCi3c7Y46lMvk8OsN_bZTbcyto,1184
|
|
48
|
-
qena_shared_lib-0.1.
|
|
49
|
-
qena_shared_lib-0.1.
|
|
50
|
-
qena_shared_lib-0.1.
|
|
48
|
+
qena_shared_lib-0.1.24.dist-info/WHEEL,sha256=k57ZwB-NkeM_6AsPnuOHv5gI5KM5kPD6Vx85WmGEcI0,78
|
|
49
|
+
qena_shared_lib-0.1.24.dist-info/METADATA,sha256=SsiY4nIss1HWNlJFm61nHv4WMFEcH1xH5cO4Ouhnh3M,19282
|
|
50
|
+
qena_shared_lib-0.1.24.dist-info/RECORD,,
|
|
File without changes
|