fastapi-factory-utilities 0.3.6__py3-none-any.whl → 0.9.1__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.
- fastapi_factory_utilities/core/api/__init__.py +1 -1
- fastapi_factory_utilities/core/api/v1/sys/health.py +1 -1
- fastapi_factory_utilities/core/app/__init__.py +4 -4
- fastapi_factory_utilities/core/app/application.py +22 -26
- fastapi_factory_utilities/core/app/builder.py +19 -35
- fastapi_factory_utilities/core/app/config.py +2 -0
- fastapi_factory_utilities/core/app/fastapi_builder.py +3 -2
- fastapi_factory_utilities/core/exceptions.py +64 -29
- fastapi_factory_utilities/core/plugins/__init__.py +2 -31
- fastapi_factory_utilities/core/plugins/abstracts.py +40 -0
- fastapi_factory_utilities/core/plugins/aiopika/__init__.py +25 -0
- fastapi_factory_utilities/core/plugins/aiopika/abstract.py +48 -0
- fastapi_factory_utilities/core/plugins/aiopika/configs.py +85 -0
- fastapi_factory_utilities/core/plugins/aiopika/depends.py +20 -0
- fastapi_factory_utilities/core/plugins/aiopika/exceptions.py +29 -0
- fastapi_factory_utilities/core/plugins/aiopika/exchange.py +69 -0
- fastapi_factory_utilities/core/plugins/aiopika/listener/__init__.py +7 -0
- fastapi_factory_utilities/core/plugins/aiopika/listener/abstract.py +72 -0
- fastapi_factory_utilities/core/plugins/aiopika/message.py +86 -0
- fastapi_factory_utilities/core/plugins/aiopika/plugins.py +84 -0
- fastapi_factory_utilities/core/plugins/aiopika/publisher/__init__.py +7 -0
- fastapi_factory_utilities/core/plugins/aiopika/publisher/abstract.py +66 -0
- fastapi_factory_utilities/core/plugins/aiopika/queue.py +88 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/__init__.py +14 -157
- fastapi_factory_utilities/core/plugins/odm_plugin/builder.py +14 -29
- fastapi_factory_utilities/core/plugins/odm_plugin/configs.py +1 -1
- fastapi_factory_utilities/core/plugins/odm_plugin/depends.py +4 -3
- fastapi_factory_utilities/core/plugins/odm_plugin/documents.py +1 -1
- fastapi_factory_utilities/core/plugins/odm_plugin/helpers.py +16 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/plugins.py +153 -0
- fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py +17 -15
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py +8 -115
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/instruments/__init__.py +85 -0
- fastapi_factory_utilities/core/plugins/opentelemetry_plugin/plugins.py +137 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/__init__.py +31 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/configs.py +12 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/depends.py +51 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/exceptions.py +13 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/plugin.py +41 -0
- fastapi_factory_utilities/core/plugins/taskiq_plugins/schedulers.py +187 -0
- fastapi_factory_utilities/core/protocols.py +1 -54
- fastapi_factory_utilities/core/security/__init__.py +5 -0
- fastapi_factory_utilities/core/security/abstracts.py +42 -0
- fastapi_factory_utilities/core/security/jwt/__init__.py +43 -0
- fastapi_factory_utilities/core/security/jwt/configs.py +32 -0
- fastapi_factory_utilities/core/security/jwt/decoders.py +130 -0
- fastapi_factory_utilities/core/security/jwt/exceptions.py +23 -0
- fastapi_factory_utilities/core/security/jwt/objects.py +107 -0
- fastapi_factory_utilities/core/security/jwt/services.py +176 -0
- fastapi_factory_utilities/core/security/jwt/stores.py +43 -0
- fastapi_factory_utilities/core/security/jwt/types.py +9 -0
- fastapi_factory_utilities/core/security/jwt/verifiers.py +46 -0
- fastapi_factory_utilities/core/security/kratos.py +43 -43
- fastapi_factory_utilities/core/services/hydra/__init__.py +20 -0
- fastapi_factory_utilities/core/services/hydra/exceptions.py +15 -0
- fastapi_factory_utilities/core/services/hydra/objects.py +26 -0
- fastapi_factory_utilities/core/services/hydra/services.py +200 -0
- fastapi_factory_utilities/core/services/status/__init__.py +2 -2
- fastapi_factory_utilities/core/services/status/exceptions.py +1 -1
- fastapi_factory_utilities/core/utils/status.py +2 -1
- fastapi_factory_utilities/core/utils/yaml_reader.py +1 -1
- fastapi_factory_utilities/example/app.py +15 -5
- fastapi_factory_utilities/example/entities/books/__init__.py +1 -1
- fastapi_factory_utilities/example/models/books/__init__.py +1 -1
- {fastapi_factory_utilities-0.3.6.dist-info → fastapi_factory_utilities-0.9.1.dist-info}/METADATA +21 -15
- fastapi_factory_utilities-0.9.1.dist-info/RECORD +111 -0
- {fastapi_factory_utilities-0.3.6.dist-info → fastapi_factory_utilities-0.9.1.dist-info}/WHEEL +1 -1
- fastapi_factory_utilities/core/app/plugin_manager/__init__.py +0 -15
- fastapi_factory_utilities/core/app/plugin_manager/exceptions.py +0 -33
- fastapi_factory_utilities/core/app/plugin_manager/plugin_manager.py +0 -190
- fastapi_factory_utilities/core/plugins/example/__init__.py +0 -31
- fastapi_factory_utilities/core/plugins/httpx_plugin/__init__.py +0 -31
- fastapi_factory_utilities/core/security/jwt.py +0 -158
- fastapi_factory_utilities-0.3.6.dist-info/RECORD +0 -78
- {fastapi_factory_utilities-0.3.6.dist-info → fastapi_factory_utilities-0.9.1.dist-info}/entry_points.txt +0 -0
- {fastapi_factory_utilities-0.3.6.dist-info → fastapi_factory_utilities-0.9.1.dist-info/licenses}/LICENSE +0 -0
|
@@ -5,10 +5,10 @@ from .services import StatusService
|
|
|
5
5
|
from .types import ComponentInstanceType, Status
|
|
6
6
|
|
|
7
7
|
__all__: list[str] = [
|
|
8
|
-
"ComponentTypeEnum",
|
|
9
8
|
"ComponentInstanceType",
|
|
9
|
+
"ComponentTypeEnum",
|
|
10
10
|
"HealthStatusEnum",
|
|
11
11
|
"ReadinessStatusEnum",
|
|
12
|
-
"StatusService",
|
|
13
12
|
"Status",
|
|
13
|
+
"StatusService",
|
|
14
14
|
]
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
```python
|
|
4
4
|
# Example of using the MonitoredAbstract
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
class MyMonitored(MonitoredAbstract):
|
|
7
8
|
def __init__(self, status_service: StatusService) -> None:
|
|
8
9
|
super().__init__(
|
|
@@ -63,9 +64,9 @@ class MonitoredAbstract(ABC):
|
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
__all__: list[str] = [
|
|
66
|
-
"MonitoredAbstract",
|
|
67
67
|
"ComponentInstanceType",
|
|
68
68
|
"ComponentTypeEnum",
|
|
69
|
+
"MonitoredAbstract",
|
|
69
70
|
"Status",
|
|
70
71
|
"StatusService",
|
|
71
72
|
]
|
|
@@ -72,7 +72,7 @@ class YamlFileReader:
|
|
|
72
72
|
try:
|
|
73
73
|
yaml_data = yaml_data[key]
|
|
74
74
|
except KeyError:
|
|
75
|
-
logger.warning(f"Base key {key}
|
|
75
|
+
logger.warning(f"Base key {key} not found in YAML file" + " from {self._yaml_base_key}")
|
|
76
76
|
return dict()
|
|
77
77
|
return yaml_data
|
|
78
78
|
|
|
@@ -7,7 +7,9 @@ from beanie import Document
|
|
|
7
7
|
from fastapi_factory_utilities.core.app.application import ApplicationAbstract
|
|
8
8
|
from fastapi_factory_utilities.core.app.builder import ApplicationGenericBuilder
|
|
9
9
|
from fastapi_factory_utilities.core.app.config import RootConfig
|
|
10
|
-
from fastapi_factory_utilities.core.plugins import
|
|
10
|
+
from fastapi_factory_utilities.core.plugins.abstracts import PluginAbstract
|
|
11
|
+
from fastapi_factory_utilities.core.plugins.odm_plugin import ODMPlugin
|
|
12
|
+
from fastapi_factory_utilities.core.plugins.opentelemetry_plugin import OpenTelemetryPlugin
|
|
11
13
|
from fastapi_factory_utilities.example.models.books.document import BookDocument
|
|
12
14
|
|
|
13
15
|
|
|
@@ -26,12 +28,11 @@ class App(ApplicationAbstract):
|
|
|
26
28
|
|
|
27
29
|
ODM_DOCUMENT_MODELS: ClassVar[list[type[Document]]] = [BookDocument]
|
|
28
30
|
|
|
29
|
-
DEFAULT_PLUGINS_ACTIVATED: ClassVar[list[PluginsEnum]] = [PluginsEnum.OPENTELEMETRY_PLUGIN, PluginsEnum.ODM_PLUGIN]
|
|
30
|
-
|
|
31
31
|
def configure(self) -> None:
|
|
32
32
|
"""Configure the application."""
|
|
33
33
|
# Prevent circular import
|
|
34
|
-
|
|
34
|
+
# pylint: disable=import-outside-toplevel
|
|
35
|
+
from .api import api_router # noqa: PLC0415
|
|
35
36
|
|
|
36
37
|
self.get_asgi_app().include_router(router=api_router)
|
|
37
38
|
|
|
@@ -47,4 +48,13 @@ class App(ApplicationAbstract):
|
|
|
47
48
|
class AppBuilder(ApplicationGenericBuilder[App]):
|
|
48
49
|
"""Application builder for the App application."""
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
def get_default_plugins(self) -> list[PluginAbstract]:
|
|
52
|
+
"""Get the default plugins."""
|
|
53
|
+
return [ODMPlugin(), OpenTelemetryPlugin()]
|
|
54
|
+
|
|
55
|
+
def __init__(self, plugins: list[PluginAbstract] | None = None) -> None:
|
|
56
|
+
"""Initialize the AppBuilder."""
|
|
57
|
+
# If no plugins are provided, use the default plugins
|
|
58
|
+
if plugins is None:
|
|
59
|
+
plugins = self.get_default_plugins()
|
|
60
|
+
super().__init__(plugins=plugins)
|
{fastapi_factory_utilities-0.3.6.dist-info → fastapi_factory_utilities-0.9.1.dist-info}/METADATA
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi_factory_utilities
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Consolidate libraries and utilities to create microservices in Python with FastAPI, Beanie,
|
|
3
|
+
Version: 0.9.1
|
|
4
|
+
Summary: Consolidate libraries and utilities to create microservices in Python with FastAPI, Beanie, Taskiq, AioPika and OpenTelemetry.
|
|
5
5
|
License: MIT
|
|
6
|
-
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: python,fastapi,beanie,taskiq,opentelemetry,microservices
|
|
7
8
|
Author: miragecentury
|
|
8
9
|
Author-email: victorien.vanroye@gmail.com
|
|
9
10
|
Maintainer: miragecentury
|
|
@@ -18,26 +19,31 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
19
|
Classifier: Topic :: Software Development :: Libraries
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
21
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist:
|
|
22
|
+
Requires-Dist: aio-pika (>=9.5.7,<10.0.0)
|
|
23
|
+
Requires-Dist: aiohttp[speedups] (>=3.12.13,<4.0.0)
|
|
24
|
+
Requires-Dist: beanie (>=2.0.0,<3.0.0)
|
|
25
|
+
Requires-Dist: fastapi (>=0.115.13,<1)
|
|
25
26
|
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.26.0,<2.0.0)
|
|
26
27
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.26.0,<2.0.0)
|
|
27
|
-
Requires-Dist: opentelemetry-instrumentation-
|
|
28
|
-
Requires-Dist: opentelemetry-instrumentation-
|
|
28
|
+
Requires-Dist: opentelemetry-instrumentation-aio-pika (>=0.59b0,<0.60)
|
|
29
|
+
Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0,<1)
|
|
30
|
+
Requires-Dist: opentelemetry-instrumentation-fastapi (>=0,<1)
|
|
31
|
+
Requires-Dist: opentelemetry-instrumentation-pymongo (>=0,<1)
|
|
29
32
|
Requires-Dist: opentelemetry-propagator-b3 (>=1.26.0,<2.0.0)
|
|
30
33
|
Requires-Dist: opentelemetry-sdk (>=1.26.0,<2.0.0)
|
|
31
34
|
Requires-Dist: pyaml (>=25.1.0,<26.0.0)
|
|
32
35
|
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
|
|
33
36
|
Requires-Dist: pyjwt (>=2.10.1,<3.0.0)
|
|
34
|
-
Requires-Dist: pymongo (>=4.9.2,<4.
|
|
37
|
+
Requires-Dist: pymongo (>=4.9.2,<4.16.0)
|
|
35
38
|
Requires-Dist: reactivex (>=4.0.4,<5.0.0)
|
|
36
39
|
Requires-Dist: structlog (>=24.1,<26.0)
|
|
37
|
-
Requires-Dist:
|
|
38
|
-
Requires-Dist:
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Requires-Dist: taskiq-dependencies (>=1.5.8,<2.0.0)
|
|
41
|
+
Requires-Dist: taskiq-fastapi (>=0.3.5,<0.4.0)
|
|
42
|
+
Requires-Dist: taskiq-redis (>=1.0.9,<2.0.0)
|
|
43
|
+
Requires-Dist: typer (>=0,<1)
|
|
44
|
+
Requires-Dist: uvicorn (>=0.34.3,<1)
|
|
45
|
+
Project-URL: Homepage, https://github.com/DeerHide/fastapi_factory_utilities
|
|
46
|
+
Project-URL: Repository, https://github.com/DeerHide/fastapi_factory_utilities
|
|
41
47
|
Description-Content-Type: text/markdown
|
|
42
48
|
|
|
43
49
|
# fastapi_factory_utilities
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
fastapi_factory_utilities/__main__.py,sha256=w8o9KpyHcxGyLHmTK8ixbIqJIsB3NbIGuAMY7OfnxrA,147
|
|
2
|
+
fastapi_factory_utilities/core/__init__.py,sha256=tt5a-MgeFt_oACkc9K5xl2rynIbca9DGqsKBDEqGzto,34
|
|
3
|
+
fastapi_factory_utilities/core/api/__init__.py,sha256=fAwgRcRry1nIyAL7CsCbpwR87n5tWnBWKEPH6QZCpp8,542
|
|
4
|
+
fastapi_factory_utilities/core/api/tags.py,sha256=3hQcTeW0FS78sPTJ2PB44dMDTSkoW-xKj7rrfKX2Lk0,154
|
|
5
|
+
fastapi_factory_utilities/core/api/v1/sys/__init__.py,sha256=mTXhpn3_KgQ1snt0-0PFmGvFr4n5srQRRADEdRSGFJM,345
|
|
6
|
+
fastapi_factory_utilities/core/api/v1/sys/health.py,sha256=LILUwfyqeBDlf4GSpkU_3bxMjZPCLanOBkMGDKtQufY,2867
|
|
7
|
+
fastapi_factory_utilities/core/api/v1/sys/readiness.py,sha256=xIY8pQLShU7KWRtlOUK5gTDyZ8aB1KBvLczC6boT-tg,1711
|
|
8
|
+
fastapi_factory_utilities/core/app/__init__.py,sha256=6Ee_zK-KzJWoOElsAnGdBz8giRJlhAPMaEzs0I3gvrA,596
|
|
9
|
+
fastapi_factory_utilities/core/app/application.py,sha256=fJTKgfqBWD1xzE7Y9ToZEBDrd1PxHtnZ7SHLmkS1S1M,4737
|
|
10
|
+
fastapi_factory_utilities/core/app/builder.py,sha256=gkmhGVYFu2zbW5sxWyh6Pn5ysdCIvn1_WqNJMKls54s,3820
|
|
11
|
+
fastapi_factory_utilities/core/app/config.py,sha256=MuV4G_M4QgZWYHoulusJLv_m4Qr2php-Cg9Jum4qkNA,7303
|
|
12
|
+
fastapi_factory_utilities/core/app/enums.py,sha256=X1upnaehYU0eHExXTde5xsH-pI9q7HZDNsOEF5PApdg,226
|
|
13
|
+
fastapi_factory_utilities/core/app/exceptions.py,sha256=tQDf0_4j5xgCbku7TL7JaZGs3_bjsWG2YLBCydQJpPw,664
|
|
14
|
+
fastapi_factory_utilities/core/app/fastapi_builder.py,sha256=7egWkS98nTiVBe2Bw5dQzDBryQCkz4w7gnY9HA24NFg,2855
|
|
15
|
+
fastapi_factory_utilities/core/exceptions.py,sha256=JeGUBiEC0dsS1uObP5SuJgUu_aCF5lCDdEFTL0Eq4W4,3221
|
|
16
|
+
fastapi_factory_utilities/core/plugins/__init__.py,sha256=7ctIv2Jx2uOUpgm8ITFRuZxHi6OXvlVS0VcbszVzvis,114
|
|
17
|
+
fastapi_factory_utilities/core/plugins/abstracts.py,sha256=p5iXmeOVD737G73I2keKV0Y-jLGQf2vYbTSR1LgrA14,1165
|
|
18
|
+
fastapi_factory_utilities/core/plugins/aiopika/__init__.py,sha256=flXanbhbjFaOsgx7jZvtW0bVLT_NXHypIPFO1tIHoCM,705
|
|
19
|
+
fastapi_factory_utilities/core/plugins/aiopika/abstract.py,sha256=TcvDwdaLV0UqFHQy6Sn3Y5Fp-1463dhL7VNB9LTKL5I,1682
|
|
20
|
+
fastapi_factory_utilities/core/plugins/aiopika/configs.py,sha256=BEPE8Ss7q_yCyuii4nywmIgh67iNLdhKxUm8tC0PdCY,3706
|
|
21
|
+
fastapi_factory_utilities/core/plugins/aiopika/depends.py,sha256=5xna571hCIdqzbo0t1CW-yzmJMSpEw_KUeJh5nBXjwQ,761
|
|
22
|
+
fastapi_factory_utilities/core/plugins/aiopika/exceptions.py,sha256=AkBKT8HVPpJDAntLNlOLp6lpQpKI-k8gxNzU24FsOF0,985
|
|
23
|
+
fastapi_factory_utilities/core/plugins/aiopika/exchange.py,sha256=MxASHfkIwFPAvIoRhGAXkzfsOPBAm5JfLkivcQtLvds,2501
|
|
24
|
+
fastapi_factory_utilities/core/plugins/aiopika/listener/__init__.py,sha256=LsTyu6kGoUm7c5OvSQTDJL7d8CG9TeARBHHVe_HGsHY,148
|
|
25
|
+
fastapi_factory_utilities/core/plugins/aiopika/listener/abstract.py,sha256=XGYfm3bZSJHG1B97tS9GqK3V9gZ3EpTEVcHyF0L9Xtc,2618
|
|
26
|
+
fastapi_factory_utilities/core/plugins/aiopika/message.py,sha256=y1tEhJWOXg1R7y7iA6F1VSZccsRPBB01IMYuU9BfikA,2885
|
|
27
|
+
fastapi_factory_utilities/core/plugins/aiopika/plugins.py,sha256=0lLYt-ZG3g3m8wi1tCCPEhTUBqaXuEJOwHEcrvP7FYc,3284
|
|
28
|
+
fastapi_factory_utilities/core/plugins/aiopika/publisher/__init__.py,sha256=MGGdygH72xHZ4QAwvbUZKQt-_mPzLmMxHyAACSNnZ_c,151
|
|
29
|
+
fastapi_factory_utilities/core/plugins/aiopika/publisher/abstract.py,sha256=PmIG5zlx-tFUAneHtbknR0Ik5flz8pMTzxcreY2hZ7s,2494
|
|
30
|
+
fastapi_factory_utilities/core/plugins/aiopika/queue.py,sha256=VivCbsIgqM36P_7VTZdOZ9kGop2m0kPCvDVQ1nEJCTo,2874
|
|
31
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/__init__.py,sha256=JsVz4GBiZRmm4qpUD1-Wsg2tRXTn-VO5fU-W1whZo4E,683
|
|
32
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/builder.py,sha256=uDyfCSoM-pNf1ThKLg21oIjJjwOCxJa28SkBQsB0FhI,8174
|
|
33
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/configs.py,sha256=5bVbtsLwJhuIvt8FCzOvk002G8qFmZumWkN75bPKatc,331
|
|
34
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/depends.py,sha256=gW-mNXmVSa31mYsUJBPX6yu92xyrNwqim5Kq29tOGI4,767
|
|
35
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/documents.py,sha256=4aQNrD26d0S542_LYmxxm07Q8SWzbGe3PCpho6iWY5Q,1102
|
|
36
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/exceptions.py,sha256=acnKJB0lGAzDs-7-LjBap8shjP3iV1a7dw7ouPVF27o,551
|
|
37
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/helpers.py,sha256=s9iEujDZbTmTb9FByJAVUzLkjQpsciQT9dytkeosKuE,463
|
|
38
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/plugins.py,sha256=PncCn_2Uj7BuYoOYQm8rl9-qcjv-qzGWCLPoNNPH5cw,6299
|
|
39
|
+
fastapi_factory_utilities/core/plugins/odm_plugin/repositories.py,sha256=dCI7oYiWyGOI1LC9JRTNjo74CC5wYsN4WjUN8l4aQ7U,11396
|
|
40
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/__init__.py,sha256=xXHn5dUxhgdDDQMpTHf3voolzS0E3zE2RFbtFHJzb38,641
|
|
41
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/builder.py,sha256=9npQImifYAbEg0lFG7KwZ8V78SNrPoaINgd8vKitdMw,12509
|
|
42
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/configs.py,sha256=pMG9leMB7rtdkdGFLIxXflV7bf9epGrrYPt2N97KZcM,3750
|
|
43
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/exceptions.py,sha256=CpsHayfQpP0zghN8y5PP6TBy-cXhHoNxBR--I86gAdE,327
|
|
44
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/helpers.py,sha256=qpTIzX67orJz7vy6SBIwRs24omMBoToJkhpurZRjPuk,1533
|
|
45
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/instruments/__init__.py,sha256=lMtdd1DSDrFcXggf0qMpB1RJC7aBqWMpOBXxC8-bqPY,3307
|
|
46
|
+
fastapi_factory_utilities/core/plugins/opentelemetry_plugin/plugins.py,sha256=v9W4bqEljcRgeSL8pf-4yZ7SGXOFmxVoljthvcLdy6Q,5356
|
|
47
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/__init__.py,sha256=zLZh8HU-oY1FL977yXt51AV95p8WCBJY2cleVUU7w6M,850
|
|
48
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/configs.py,sha256=O2rgFFWJNBUZ7ozfhM0Lj5Te-58qBNrQtw_N0mosAu4,304
|
|
49
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/depends.py,sha256=KFYiisQCpkmlqXY0Ma6N6lmJqoM_ukSi24ESqaijaq8,1593
|
|
50
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/exceptions.py,sha256=1Xq_DqDFiQm2YU-2pGxziy-EeMhHiUsUwV0XdY_rQls,456
|
|
51
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/plugin.py,sha256=gUlU2s7aLB2lkAAPdLqVc-BY16PessSYTGMGgNcKCSA,1602
|
|
52
|
+
fastapi_factory_utilities/core/plugins/taskiq_plugins/schedulers.py,sha256=82Yh7Y_MUxiWjrHPnsW_Ax-CWREAT6eC_bVl-HW5a3E,7208
|
|
53
|
+
fastapi_factory_utilities/core/protocols.py,sha256=w5FQqMAZ_OulG5hQWkoOapNSnxsjBPq4EjvWNXXdI_c,859
|
|
54
|
+
fastapi_factory_utilities/core/security/__init__.py,sha256=C_EnEZLMrhmAktNmSD80-0eqhs38AFnTmp-3UC7L0cg,119
|
|
55
|
+
fastapi_factory_utilities/core/security/abstracts.py,sha256=xas-gFTqWzxWMZNZx4qdtAzYW_XA8vH2N1wlBx0CuN8,1247
|
|
56
|
+
fastapi_factory_utilities/core/security/jwt/__init__.py,sha256=SffjbZ5eq7ZuJvufBkCpp2wRf5ZTOsiKhwdMpmQ7oHg,1286
|
|
57
|
+
fastapi_factory_utilities/core/security/jwt/configs.py,sha256=FaqBXdH3W1e95DrFl1QMqF6Teyp5ZvGq42EC8GCwGNM,1367
|
|
58
|
+
fastapi_factory_utilities/core/security/jwt/decoders.py,sha256=byj--PbnVbBHrZm6lWE2SH3XX37zPuWdujcLgogdB1U,4935
|
|
59
|
+
fastapi_factory_utilities/core/security/jwt/exceptions.py,sha256=9kxA4JLq9tfBfnwf-Wadpy9RiU8IjcijifqUS8KFhz0,642
|
|
60
|
+
fastapi_factory_utilities/core/security/jwt/objects.py,sha256=z4geVMnrZVPV0aaf-p0NIY4WHXhQox2UiKyHTHH5DOc,3986
|
|
61
|
+
fastapi_factory_utilities/core/security/jwt/services.py,sha256=8NAXI8RniXZAzNJzg8I9nisu5ch8fP83c9Tm-vdM4p8,7240
|
|
62
|
+
fastapi_factory_utilities/core/security/jwt/stores.py,sha256=LhAAputlPFBZyVMhm5blHKX6eKYo_GxrULANgYBWKio,1193
|
|
63
|
+
fastapi_factory_utilities/core/security/jwt/types.py,sha256=FO9fIDh67pK0iVzQGeH_M9AWRqCQQS2S7GqkHkZBQBo,288
|
|
64
|
+
fastapi_factory_utilities/core/security/jwt/verifiers.py,sha256=bf6nlm3dCk4Ej1ncB-gfIRRXc5I5np9IzAo1vDhwo1c,1292
|
|
65
|
+
fastapi_factory_utilities/core/security/kratos.py,sha256=Nfol2sIHlRSw5JdzzFsa89_C15lrLLQMeUd55QAGZDc,3193
|
|
66
|
+
fastapi_factory_utilities/core/services/hydra/__init__.py,sha256=b6q22Qiapcg4xzoWNI5_qyT5wwcRJ7hiK1ItGmspgW8,616
|
|
67
|
+
fastapi_factory_utilities/core/services/hydra/exceptions.py,sha256=ePMrfZturU2IVcxOebR0CbVKKqprce_fK-4UXbPPgNI,450
|
|
68
|
+
fastapi_factory_utilities/core/services/hydra/objects.py,sha256=2CeV_4zmwwpfbXQ0TM9B_UnNkZuIRXweFP_VALBo57c,601
|
|
69
|
+
fastapi_factory_utilities/core/services/hydra/services.py,sha256=JvRyAW7J5zG-r4hE6Y0VzeQZuOcwfjU4eGgo6k_bqJg,8235
|
|
70
|
+
fastapi_factory_utilities/core/services/kratos/__init__.py,sha256=DaC29-Ol0WR5vX56IHLGDXP9UrhISq0Juhg_sJTasw4,368
|
|
71
|
+
fastapi_factory_utilities/core/services/kratos/enums.py,sha256=ULJppowlZbOjdnUIXQyI4_nHmHZoNnv7-M1CYQBYXFY,220
|
|
72
|
+
fastapi_factory_utilities/core/services/kratos/exceptions.py,sha256=xAX01-lQvPpADgcwhB5YWSy1UqAxG38s2rlU9AJBJd8,472
|
|
73
|
+
fastapi_factory_utilities/core/services/kratos/objects.py,sha256=a0npt4Q6d9UbF0w3e6EvyKLwMWO2l639_dFjruA8_2c,980
|
|
74
|
+
fastapi_factory_utilities/core/services/kratos/services.py,sha256=RFKrME6M6omWiHORMBCSyvIG0BsimQaCfnmtsOdFfsg,3158
|
|
75
|
+
fastapi_factory_utilities/core/services/status/__init__.py,sha256=kkR2Xx-kbHb_QXkkBSUNIK5y_eNM4YCElFftBAooIY0,370
|
|
76
|
+
fastapi_factory_utilities/core/services/status/enums.py,sha256=IUxWAd0Ecknri4BqzaqoDRRhT_8LdcgtQcNqgNVDXGE,599
|
|
77
|
+
fastapi_factory_utilities/core/services/status/exceptions.py,sha256=nA22c9djJMTRh_uN2WD0iKs-wRLZ09hhdPEx3slt1Bw,840
|
|
78
|
+
fastapi_factory_utilities/core/services/status/health_calculator_strategies.py,sha256=p2KKJo-dq1j9iWHT0mvlBKtldH9m8l31aytLkUsb9nQ,1634
|
|
79
|
+
fastapi_factory_utilities/core/services/status/readiness_calculator_strategies.py,sha256=hA1LX2pSxva-7bVaQ0dw8NpTbl1ZWDtXd9xzqQUGUsI,1354
|
|
80
|
+
fastapi_factory_utilities/core/services/status/services.py,sha256=qtgYdnxNQMbb6q6G9uGasRO3lZcpiWNmw1padPkh6jA,8490
|
|
81
|
+
fastapi_factory_utilities/core/services/status/types.py,sha256=GJOGRra6NtpUS4q1cr4cdWR0BbIUtEwP7vQX-sXX5jQ,3297
|
|
82
|
+
fastapi_factory_utilities/core/utils/configs.py,sha256=qM0pCrsK8ZyfCoyova_VrhR4eUX3LSPCbWunGMWcSVg,2581
|
|
83
|
+
fastapi_factory_utilities/core/utils/importlib.py,sha256=DYcPo7K0s95WV5xxtucpufWsTj8Pxv25sWunDmmNUYI,797
|
|
84
|
+
fastapi_factory_utilities/core/utils/log.py,sha256=6V9CL3bQio4e47YxcSXM2JQRGhVxuBfmcEbcF4RtCfQ,6393
|
|
85
|
+
fastapi_factory_utilities/core/utils/status.py,sha256=ADdi4NzkJy0qNVC86tKV09wdpuPhuCKSrvYn9tzNVn8,1934
|
|
86
|
+
fastapi_factory_utilities/core/utils/uvicorn.py,sha256=XThylG-nOPVL00w6MIWGODnweoM7VxmpSFcyoPcmqns,2609
|
|
87
|
+
fastapi_factory_utilities/core/utils/yaml_reader.py,sha256=2XenSHqymZsgff70upPZtyx0-BsiUdTENKmrxaOBLeE,6100
|
|
88
|
+
fastapi_factory_utilities/example/__init__.py,sha256=LEKnPTBcgDyfHeOjlVxjK5lFdFqS-7-mHDuVuM2Jh_Y,206
|
|
89
|
+
fastapi_factory_utilities/example/__main__.py,sha256=Iwp_6rK7Lcv2F-XAKn6xjxQHOWjx2OjgwKAr91tfUfk,135
|
|
90
|
+
fastapi_factory_utilities/example/api/__init__.py,sha256=qI82eeSwVjR6jSkX1pxm8ALv9WPQ_iHurFY4G2K7VzE,554
|
|
91
|
+
fastapi_factory_utilities/example/api/books/__init__.py,sha256=zXARBnjywJwg1XsLbcixYWcHH4uC9mF-kbbX4P8cVgA,160
|
|
92
|
+
fastapi_factory_utilities/example/api/books/responses.py,sha256=21WeD6bdg0MCD_0vRHwmsL4W79iDcG9NnDLemXysc84,540
|
|
93
|
+
fastapi_factory_utilities/example/api/books/routes.py,sha256=bwg8Bhvoj9vx2SdwunzFS-Z3cHECtjl_yGdo8MfiGEM,1529
|
|
94
|
+
fastapi_factory_utilities/example/app.py,sha256=MInt71wnDEC9yqVJeT3hChj7DRmg7sI3Ta0KkfubdyU,2076
|
|
95
|
+
fastapi_factory_utilities/example/application.yaml,sha256=5xRyFSuMxmgZ5Mikai94UqKYJ7PxJp8omlXobTjv14M,485
|
|
96
|
+
fastapi_factory_utilities/example/entities/books/__init__.py,sha256=cpTMhLpenb359lOT9HHUv6DzKX8fKl4WCzcsB3ddk6Q,185
|
|
97
|
+
fastapi_factory_utilities/example/entities/books/entities.py,sha256=rLE01lE7U6WizrD5ZHMRwkynd8_dWF6DltBFH61f-Do,405
|
|
98
|
+
fastapi_factory_utilities/example/entities/books/enums.py,sha256=lXYUvhIkT1pi0teflMpnqeafeiBZMokyWxoFLgzV6a8,330
|
|
99
|
+
fastapi_factory_utilities/example/entities/books/types.py,sha256=7LYGPu-CcI3noIORJyIZlVF-CBugWPXEqgDzWrO3XmQ,1558
|
|
100
|
+
fastapi_factory_utilities/example/models/__init__.py,sha256=RJmp3R9bhbQv7n0WOlsHP65LqbEs_DjF9hzYKwYTRGo,22
|
|
101
|
+
fastapi_factory_utilities/example/models/books/__init__.py,sha256=IPS3rLLnZncV-VAxgsipxUD7l4r04ewo_Hx2Naj2lT0,181
|
|
102
|
+
fastapi_factory_utilities/example/models/books/document.py,sha256=lYJfMGr5GqEEsn7L--PFs75hC2q-jQx77wl7EhTrp5U,568
|
|
103
|
+
fastapi_factory_utilities/example/models/books/repository.py,sha256=7K63uAsSEGZ2EXqufU4Tc8KpymgXK8JX8WjAE2Sw8ok,387
|
|
104
|
+
fastapi_factory_utilities/example/services/books/__init__.py,sha256=Z06yNRoA7Zg3TGN-Q9rrvJg6Bbx-qJw661MVwukV6vQ,148
|
|
105
|
+
fastapi_factory_utilities/example/services/books/services.py,sha256=-x7d4hotUWLzWo5uImMjFmtNcSTHwWv2bfttIbYYKbA,5380
|
|
106
|
+
fastapi_factory_utilities/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
107
|
+
fastapi_factory_utilities-0.9.1.dist-info/METADATA,sha256=u7kvtm77d0XNN9bgzakMsN47MFmaBcQZ2nk18Qxio-8,3740
|
|
108
|
+
fastapi_factory_utilities-0.9.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
109
|
+
fastapi_factory_utilities-0.9.1.dist-info/entry_points.txt,sha256=IK0VcBexXo4uXQmTrbfhhnnfq4GmXPRn0GBB8hzlsq4,101
|
|
110
|
+
fastapi_factory_utilities-0.9.1.dist-info/licenses/LICENSE,sha256=iO1nLzMMst6vEiqgSUrfrbetM7b0bvdzXhbed5tqG8o,1074
|
|
111
|
+
fastapi_factory_utilities-0.9.1.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"""Provide PluginManager."""
|
|
2
|
-
|
|
3
|
-
from .exceptions import (
|
|
4
|
-
InvalidPluginError,
|
|
5
|
-
PluginManagerError,
|
|
6
|
-
PluginPreConditionNotMetError,
|
|
7
|
-
)
|
|
8
|
-
from .plugin_manager import PluginManager
|
|
9
|
-
|
|
10
|
-
__all__: list[str] = [
|
|
11
|
-
"PluginManager",
|
|
12
|
-
"PluginManagerError",
|
|
13
|
-
"InvalidPluginError",
|
|
14
|
-
"PluginPreConditionNotMetError",
|
|
15
|
-
]
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"""Provide the exceptions for the plugin manager."""
|
|
2
|
-
|
|
3
|
-
from fastapi_factory_utilities.core.exceptions import FastAPIFactoryUtilitiesError
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class PluginManagerError(FastAPIFactoryUtilitiesError):
|
|
7
|
-
"""Generic plugin manager error."""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class InvalidPluginError(PluginManagerError):
|
|
11
|
-
"""The plugin is invalid."""
|
|
12
|
-
|
|
13
|
-
def __init__(self, plugin_name: str, message: str) -> None:
|
|
14
|
-
"""Instantiate the exception.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
plugin_name (str): The plugin name.
|
|
18
|
-
message (str): The message
|
|
19
|
-
"""
|
|
20
|
-
super().__init__(message=f"Invalid plugin: {plugin_name}, {message}")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class PluginPreConditionNotMetError(PluginManagerError):
|
|
24
|
-
"""The plugin pre-condition is not met."""
|
|
25
|
-
|
|
26
|
-
def __init__(self, plugin_name: str, message: str) -> None:
|
|
27
|
-
"""Instantiate the exception.
|
|
28
|
-
|
|
29
|
-
Args:
|
|
30
|
-
plugin_name (str): The plugin name.
|
|
31
|
-
message (str): The message
|
|
32
|
-
"""
|
|
33
|
-
super().__init__(message=f"Plugin pre-condition not met: {plugin_name}, {message}")
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"""Plugin manager.
|
|
2
|
-
|
|
3
|
-
This module provides the plugin manager for the application.
|
|
4
|
-
|
|
5
|
-
Objective:
|
|
6
|
-
- Provide a way to manage plugins for the application.
|
|
7
|
-
- The plugins are activated based on the configuration.
|
|
8
|
-
- The plugins are checked for pre-conditions.
|
|
9
|
-
- The plugins are loaded on application load.
|
|
10
|
-
- The plugins are started on application startup.
|
|
11
|
-
- The plugins are stopped on application shutdown.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
from importlib import import_module
|
|
15
|
-
from types import ModuleType
|
|
16
|
-
from typing import Self
|
|
17
|
-
|
|
18
|
-
from fastapi_factory_utilities.core.plugins import PluginsEnum, PluginState
|
|
19
|
-
from fastapi_factory_utilities.core.protocols import (
|
|
20
|
-
ApplicationAbstractProtocol,
|
|
21
|
-
PluginProtocol,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
from .exceptions import InvalidPluginError, PluginPreConditionNotMetError
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class PluginManager:
|
|
28
|
-
"""Plugin manager for the application."""
|
|
29
|
-
|
|
30
|
-
DEFAULT_PLUGIN_PACKAGE: str = "fastapi_factory_utilities.core.plugins"
|
|
31
|
-
|
|
32
|
-
@classmethod
|
|
33
|
-
def _import_module(cls, name: str, package: str) -> ModuleType:
|
|
34
|
-
"""Import the module. This is a wrapper around the import_module function to be able to mock it in the tests.
|
|
35
|
-
|
|
36
|
-
Args:
|
|
37
|
-
name (str): The name of the module.
|
|
38
|
-
package (str): The package of the module.
|
|
39
|
-
|
|
40
|
-
Returns:
|
|
41
|
-
ModuleType: The module.
|
|
42
|
-
|
|
43
|
-
Raises:
|
|
44
|
-
ImportError: If the module cannot be imported.
|
|
45
|
-
ModuleNotFoundError: If the module is not found.
|
|
46
|
-
"""
|
|
47
|
-
return import_module(name=f"{package}.{name}")
|
|
48
|
-
|
|
49
|
-
@classmethod
|
|
50
|
-
def _check_pre_conditions(
|
|
51
|
-
cls, plugin_package: str, want_to_activate_plugins: list[PluginsEnum], application: ApplicationAbstractProtocol
|
|
52
|
-
) -> list[PluginProtocol]:
|
|
53
|
-
"""Check the pre-conditions for the plugins.
|
|
54
|
-
|
|
55
|
-
Args:
|
|
56
|
-
plugin_package (str): The package for the plugins.
|
|
57
|
-
want_to_activate_plugins (list[PluginsEnum]): The plugins to activate.
|
|
58
|
-
application (BaseApplicationProtocol): The application.
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
list[PluginProtocol]: The activated plugins.
|
|
62
|
-
|
|
63
|
-
Raises:
|
|
64
|
-
InvalidPluginError: If the plugin is invalid.
|
|
65
|
-
PluginPreConditionNotMetError: If the pre-conditions are not met.
|
|
66
|
-
"""
|
|
67
|
-
plugins: list[PluginProtocol] = []
|
|
68
|
-
|
|
69
|
-
for plugin_enum in want_to_activate_plugins:
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
# Using a custom import function to be able to mock it in the tests.
|
|
73
|
-
plugin_module: ModuleType = cls._import_module(name=plugin_enum.value, package=plugin_package)
|
|
74
|
-
except (ImportError, ModuleNotFoundError) as import_error:
|
|
75
|
-
# TODO: Later, if we introduce extra mecanism to manage dependencies,
|
|
76
|
-
# we must handle a part of the error here. To be able to provide a better error message.
|
|
77
|
-
# For now, we just raise the error.
|
|
78
|
-
raise InvalidPluginError(
|
|
79
|
-
plugin_name=plugin_enum.value, message="Error importing the plugin "
|
|
80
|
-
) from import_error
|
|
81
|
-
|
|
82
|
-
if not isinstance(plugin_module, PluginProtocol):
|
|
83
|
-
raise InvalidPluginError(
|
|
84
|
-
plugin_name=plugin_enum.value, message="The plugin does not implement the PluginProtocol"
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
if not plugin_module.pre_conditions_check(application=application):
|
|
88
|
-
raise PluginPreConditionNotMetError(
|
|
89
|
-
plugin_name=plugin_enum.value, message="The pre-conditions are not met"
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
plugins.append(plugin_module)
|
|
93
|
-
|
|
94
|
-
return plugins
|
|
95
|
-
|
|
96
|
-
def __init__(self, activated: list[PluginsEnum] | None = None, plugin_package: str | None = None) -> None:
|
|
97
|
-
"""Instanciate the plugin manager."""
|
|
98
|
-
self._plugin_package: str = plugin_package or self.DEFAULT_PLUGIN_PACKAGE
|
|
99
|
-
self._plugins_wanted_to_be_activated: list[PluginsEnum] = activated or []
|
|
100
|
-
self._activated_plugins: list[PluginProtocol] = []
|
|
101
|
-
self._states: list[PluginState] = []
|
|
102
|
-
|
|
103
|
-
def activate(self, plugin: PluginsEnum) -> Self:
|
|
104
|
-
"""Activate a plugin.
|
|
105
|
-
|
|
106
|
-
Args:
|
|
107
|
-
plugin (PluginsEnum): The plugin to activate.
|
|
108
|
-
|
|
109
|
-
Returns:
|
|
110
|
-
Self: The plugin manager.
|
|
111
|
-
"""
|
|
112
|
-
self._plugins_wanted_to_be_activated.append(plugin)
|
|
113
|
-
|
|
114
|
-
return self
|
|
115
|
-
|
|
116
|
-
@property
|
|
117
|
-
def states(self) -> list[PluginState]:
|
|
118
|
-
"""Get the states."""
|
|
119
|
-
return self._states
|
|
120
|
-
|
|
121
|
-
def add_application_context(self, application: ApplicationAbstractProtocol) -> Self:
|
|
122
|
-
"""Add the application context to the plugins.
|
|
123
|
-
|
|
124
|
-
Args:
|
|
125
|
-
application (BaseApplicationProtocol): The application.
|
|
126
|
-
|
|
127
|
-
Returns:
|
|
128
|
-
Self: The plugin manager.
|
|
129
|
-
"""
|
|
130
|
-
self._application: ApplicationAbstractProtocol = application
|
|
131
|
-
|
|
132
|
-
return self
|
|
133
|
-
|
|
134
|
-
def add_states(self, states: list[PluginState]) -> Self:
|
|
135
|
-
"""Add the states to the plugin manager.
|
|
136
|
-
|
|
137
|
-
Args:
|
|
138
|
-
states (list[PluginState]): The states.
|
|
139
|
-
|
|
140
|
-
Returns:
|
|
141
|
-
Self: The plugin manager.
|
|
142
|
-
"""
|
|
143
|
-
for state in states:
|
|
144
|
-
self._states.append(state)
|
|
145
|
-
return self
|
|
146
|
-
|
|
147
|
-
def clear_states(self) -> Self:
|
|
148
|
-
"""Clear the states."""
|
|
149
|
-
self._states = []
|
|
150
|
-
return self
|
|
151
|
-
|
|
152
|
-
def load(self) -> Self:
|
|
153
|
-
"""Load the plugins.
|
|
154
|
-
|
|
155
|
-
Returns:
|
|
156
|
-
Self: The plugin manager.
|
|
157
|
-
|
|
158
|
-
Raises:
|
|
159
|
-
InvalidPluginError: If the plugin is invalid.
|
|
160
|
-
PluginPreConditionNotMetError: If the pre-conditions are not met.
|
|
161
|
-
|
|
162
|
-
"""
|
|
163
|
-
# Remove duplicates.
|
|
164
|
-
self._plugins_wanted_to_be_activated = list(set(self._plugins_wanted_to_be_activated))
|
|
165
|
-
# Check the pre-conditions for the plugins.
|
|
166
|
-
self._activated_plugins = self._check_pre_conditions(
|
|
167
|
-
plugin_package=self._plugin_package,
|
|
168
|
-
want_to_activate_plugins=self._plugins_wanted_to_be_activated,
|
|
169
|
-
application=self._application,
|
|
170
|
-
)
|
|
171
|
-
# Load from the previous check.
|
|
172
|
-
for plugin in self._activated_plugins:
|
|
173
|
-
self.add_states(states=plugin.on_load(application=self._application) or [])
|
|
174
|
-
|
|
175
|
-
return self
|
|
176
|
-
|
|
177
|
-
async def trigger_startup(self) -> Self:
|
|
178
|
-
"""Trigger the startup of the plugins."""
|
|
179
|
-
for plugin in self._activated_plugins:
|
|
180
|
-
states: list[PluginState] | None = await plugin.on_startup(application=self._application)
|
|
181
|
-
self.add_states(states=states or [])
|
|
182
|
-
|
|
183
|
-
return self
|
|
184
|
-
|
|
185
|
-
async def trigger_shutdown(self) -> Self:
|
|
186
|
-
"""Trigger the shutdown of the plugins."""
|
|
187
|
-
for plugin in self._activated_plugins:
|
|
188
|
-
await plugin.on_shutdown(application=self._application)
|
|
189
|
-
|
|
190
|
-
return self
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"""Example Plugin Module."""
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
if TYPE_CHECKING:
|
|
6
|
-
from fastapi_factory_utilities.core.plugins import PluginState
|
|
7
|
-
from fastapi_factory_utilities.core.protocols import ApplicationAbstractProtocol
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def pre_conditions_check(application: "ApplicationAbstractProtocol") -> bool: # pylint: disable=unused-argument
|
|
11
|
-
"""Check the pre-conditions for the example plugin."""
|
|
12
|
-
return True
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def on_load(
|
|
16
|
-
application: "ApplicationAbstractProtocol", # pylint: disable=unused-argument
|
|
17
|
-
) -> list["PluginState"] | None:
|
|
18
|
-
"""Actions to perform on load for the example plugin."""
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async def on_startup(
|
|
23
|
-
application: "ApplicationAbstractProtocol", # pylint: disable=unused-argument
|
|
24
|
-
) -> list["PluginState"] | None:
|
|
25
|
-
"""Actions to perform on startup for the example plugin."""
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
async def on_shutdown(application: "ApplicationAbstractProtocol") -> None: # pylint: disable=unused-argument
|
|
30
|
-
"""Actions to perform on shutdown for the example plugin."""
|
|
31
|
-
return
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"""Httpx Plugin Module."""
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
if TYPE_CHECKING:
|
|
6
|
-
from fastapi_factory_utilities.core.plugins import PluginState
|
|
7
|
-
from fastapi_factory_utilities.core.protocols import ApplicationAbstractProtocol
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def pre_conditions_check(application: "ApplicationAbstractProtocol") -> bool: # pylint: disable=unused-argument
|
|
11
|
-
"""Check the pre-conditions for the example plugin."""
|
|
12
|
-
return True
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def on_load(
|
|
16
|
-
application: "ApplicationAbstractProtocol", # pylint: disable=unused-argument
|
|
17
|
-
) -> list["PluginState"] | None:
|
|
18
|
-
"""Actions to perform on load for the example plugin."""
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
async def on_startup(
|
|
23
|
-
application: "ApplicationAbstractProtocol", # pylint: disable=unused-argument
|
|
24
|
-
) -> list["PluginState"] | None:
|
|
25
|
-
"""Actions to perform on startup for the example plugin."""
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
async def on_shutdown(application: "ApplicationAbstractProtocol") -> None: # pylint: disable=unused-argument
|
|
30
|
-
"""Actions to perform on shutdown for the example plugin."""
|
|
31
|
-
return
|