fastapi-mongo-base 1.4.1__tar.gz → 1.4.3__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.
- {fastapi_mongo_base-1.4.1/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-1.4.3}/PKG-INFO +1 -1
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/pyproject.toml +1 -1
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/prometheus/mongo.py +12 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/basic.py +41 -12
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3/src/fastapi_mongo_base.egg-info}/PKG-INFO +1 -1
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/LICENSE.txt +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/MANIFEST.in +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/README.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/boilerplate.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/changelog.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/contributing.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/endpoints.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/extra.css +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/index.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/installation.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/license.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/quickstart.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/settings.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/tutorial.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/docs/usage.md +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/mkdocs.yml +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/pytest.ini +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/setup.cfg +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/__init__.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/__init__.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/app_factory.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/config.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/db.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/enums.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/error_responses.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/errors/mongodb_errors.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/errors/resource_errors.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/exceptions.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/middlewares/prometheus.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/sentry.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/models.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/py.typed +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/routes.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/schemas.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/sql.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/tasks.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/__init__.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/bsontools.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/timezone.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/usso_routes.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/SOURCES.txt +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/dependency_links.txt +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/requires.txt +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/top_level.txt +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/__init__.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/app/__init__.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/app/logs/app.log +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/app/main.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/app/server.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/conftest.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_apis.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_app.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_db.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_mongodb_errors.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_openapi_errors.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_resource_errors.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_sentry.py +0 -0
- {fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/tests/test_usso_routes_workspace.py +0 -0
{fastapi_mongo_base-1.4.1/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-1.4.3}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-mongo-base
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.3
|
|
4
4
|
Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
|
|
5
5
|
Author-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
6
6
|
Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "fastapi-mongo-base"
|
|
7
|
-
version = "1.4.
|
|
7
|
+
version = "1.4.3"
|
|
8
8
|
description = "A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -65,6 +65,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
65
65
|
self.in_use_connections = 0
|
|
66
66
|
|
|
67
67
|
def _update_metrics(self) -> None:
|
|
68
|
+
if pool_connections is None:
|
|
69
|
+
return
|
|
68
70
|
pool_connections.labels(
|
|
69
71
|
database=self.database_name,
|
|
70
72
|
state="available",
|
|
@@ -109,6 +111,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
109
111
|
"""Record a MongoDB connection creation event."""
|
|
110
112
|
del event
|
|
111
113
|
|
|
114
|
+
if connections_created_total is None:
|
|
115
|
+
return
|
|
112
116
|
with self._lock:
|
|
113
117
|
connections_created_total.labels(
|
|
114
118
|
database=self.database_name,
|
|
@@ -121,6 +125,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
121
125
|
"""Record a MongoDB connection readiness event."""
|
|
122
126
|
del event
|
|
123
127
|
|
|
128
|
+
if connections_ready_total is None:
|
|
129
|
+
return
|
|
124
130
|
with self._lock:
|
|
125
131
|
self.available_connections += 1
|
|
126
132
|
|
|
@@ -137,6 +143,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
137
143
|
"""Record a MongoDB connection closure event."""
|
|
138
144
|
del event
|
|
139
145
|
|
|
146
|
+
if connections_closed_total is None:
|
|
147
|
+
return
|
|
140
148
|
with self._lock:
|
|
141
149
|
if self.in_use_connections > 0:
|
|
142
150
|
self.in_use_connections -= 1
|
|
@@ -159,6 +167,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
159
167
|
"""Record the start of a MongoDB connection checkout attempt."""
|
|
160
168
|
del event
|
|
161
169
|
|
|
170
|
+
if checkouts_started_total is None:
|
|
171
|
+
return
|
|
162
172
|
with self._lock:
|
|
163
173
|
checkouts_started_total.labels(
|
|
164
174
|
database=self.database_name,
|
|
@@ -169,6 +179,8 @@ class DatabasePoolMonitor(monitoring.ConnectionPoolListener):
|
|
|
169
179
|
event: monitoring.ConnectionCheckOutFailedEvent,
|
|
170
180
|
) -> None:
|
|
171
181
|
"""Record a failed MongoDB connection checkout attempt."""
|
|
182
|
+
if checkouts_failed_total is None:
|
|
183
|
+
return
|
|
172
184
|
with self._lock:
|
|
173
185
|
checkouts_failed_total.labels(
|
|
174
186
|
database=self.database_name,
|
|
@@ -328,9 +328,21 @@ async def gather_sync(
|
|
|
328
328
|
R = TypeVar("R")
|
|
329
329
|
|
|
330
330
|
|
|
331
|
+
def _resolve_mock(
|
|
332
|
+
mock_response: R | Callable[..., R | Awaitable[R]],
|
|
333
|
+
*args: object,
|
|
334
|
+
**kwargs: object,
|
|
335
|
+
) -> R | Awaitable[R]:
|
|
336
|
+
if callable(mock_response):
|
|
337
|
+
return mock_response(*args, **kwargs)
|
|
338
|
+
return mock_response
|
|
339
|
+
|
|
340
|
+
|
|
331
341
|
def debug_mode_mock(
|
|
332
342
|
mock_response: R | Callable[..., R | Awaitable[R]],
|
|
333
|
-
) -> Callable[
|
|
343
|
+
) -> Callable[
|
|
344
|
+
[Callable[..., R | Awaitable[R]]], Callable[..., R | Awaitable[R]]
|
|
345
|
+
]:
|
|
334
346
|
"""
|
|
335
347
|
Return a mock response if debug is enabled.
|
|
336
348
|
|
|
@@ -340,22 +352,39 @@ def debug_mode_mock(
|
|
|
340
352
|
Returns:
|
|
341
353
|
A decorator that returns a mock response if debug is enabled.
|
|
342
354
|
"""
|
|
343
|
-
from ..core.config import Settings
|
|
344
355
|
|
|
345
356
|
def decorator(
|
|
346
|
-
func: Callable[..., Awaitable[R]],
|
|
347
|
-
) -> Callable[..., Awaitable[R]]:
|
|
357
|
+
func: Callable[..., R | Awaitable[R]],
|
|
358
|
+
) -> Callable[..., R | Awaitable[R]]:
|
|
359
|
+
|
|
360
|
+
from ..core.config import Settings
|
|
361
|
+
|
|
348
362
|
@functools.wraps(func)
|
|
349
|
-
async def
|
|
363
|
+
async def async_wrapper(*args: object, **kwargs: object) -> R:
|
|
350
364
|
if Settings.debug:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return result
|
|
356
|
-
return mock_response
|
|
365
|
+
result = _resolve_mock(mock_response, *args, **kwargs)
|
|
366
|
+
if isinstance(result, Awaitable):
|
|
367
|
+
return await result
|
|
368
|
+
return result
|
|
357
369
|
return await func(*args, **kwargs)
|
|
358
370
|
|
|
359
|
-
|
|
371
|
+
@functools.wraps(func)
|
|
372
|
+
def sync_wrapper(*args: object, **kwargs: object) -> R:
|
|
373
|
+
if Settings.debug:
|
|
374
|
+
result = _resolve_mock(mock_response, *args, **kwargs)
|
|
375
|
+
if isinstance(result, Awaitable):
|
|
376
|
+
msg = (
|
|
377
|
+
"debug_mode_mock callable returned "
|
|
378
|
+
"Awaitable for sync function"
|
|
379
|
+
)
|
|
380
|
+
raise TypeError(msg)
|
|
381
|
+
return result
|
|
382
|
+
return func(*args, **kwargs)
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
async_wrapper
|
|
386
|
+
if inspect.iscoroutinefunction(func)
|
|
387
|
+
else sync_wrapper
|
|
388
|
+
)
|
|
360
389
|
|
|
361
390
|
return decorator
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3/src/fastapi_mongo_base.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-mongo-base
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.3
|
|
4
4
|
Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
|
|
5
5
|
Author-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
6
6
|
Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
|
|
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
|
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/__init__.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/app_factory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/error_responses.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/core/exceptions.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
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/__init__.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/bsontools.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/timezone.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base/utils/usso_routes.py
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/requires.txt
RENAMED
|
File without changes
|
{fastapi_mongo_base-1.4.1 → fastapi_mongo_base-1.4.3}/src/fastapi_mongo_base.egg-info/top_level.txt
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
|