maleo-foundation 0.3.31__py3-none-any.whl → 0.3.32__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.
- maleo_foundation/managers/service.py +22 -9
- {maleo_foundation-0.3.31.dist-info → maleo_foundation-0.3.32.dist-info}/METADATA +1 -1
- {maleo_foundation-0.3.31.dist-info → maleo_foundation-0.3.32.dist-info}/RECORD +5 -5
- {maleo_foundation-0.3.31.dist-info → maleo_foundation-0.3.32.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.3.31.dist-info → maleo_foundation-0.3.32.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import asyncio
|
1
2
|
from fastapi import FastAPI, APIRouter
|
2
3
|
from fastapi.exceptions import RequestValidationError
|
3
4
|
from google.oauth2.service_account import Credentials
|
@@ -152,6 +153,20 @@ class ServiceManager:
|
|
152
153
|
def loggers(self) -> Loggers:
|
153
154
|
return self._loggers
|
154
155
|
|
156
|
+
async def _clear_cache(self) -> None:
|
157
|
+
prefix = self.configurations.service.key
|
158
|
+
async for key in self._redis.scan_iter(f"{prefix}*"):
|
159
|
+
await self._redis.delete(key)
|
160
|
+
|
161
|
+
def check_redis_connection(self) -> bool:
|
162
|
+
try:
|
163
|
+
self._redis.ping()
|
164
|
+
self._loggers.application.info("Redis connection check successful.")
|
165
|
+
return True
|
166
|
+
except RedisError as e:
|
167
|
+
self._loggers.application.error(f"Redis connection check failed: {e}", exc_info=True)
|
168
|
+
return False
|
169
|
+
|
155
170
|
def _initialize_cache(self) -> None:
|
156
171
|
self._redis = Redis(
|
157
172
|
host=self.configurations.cache.redis.host,
|
@@ -161,7 +176,14 @@ class ServiceManager:
|
|
161
176
|
decode_responses=self.configurations.cache.redis.decode_responses,
|
162
177
|
health_check_interval=self.configurations.cache.redis.health_check_interval
|
163
178
|
)
|
179
|
+
self.check_redis_connection()
|
164
180
|
self._cache = CacheManagers(redis=self._redis)
|
181
|
+
try:
|
182
|
+
asyncio.run(self._clear_cache())
|
183
|
+
except RuntimeError:
|
184
|
+
loop = asyncio.new_event_loop()
|
185
|
+
asyncio.set_event_loop(loop)
|
186
|
+
loop.run_until_complete(self._clear_cache())
|
165
187
|
|
166
188
|
@property
|
167
189
|
def redis(self) -> Redis:
|
@@ -171,15 +193,6 @@ class ServiceManager:
|
|
171
193
|
def cache(self) -> CacheManagers:
|
172
194
|
return self._cache
|
173
195
|
|
174
|
-
def check_redis_connection(self) -> bool:
|
175
|
-
try:
|
176
|
-
self._redis.ping()
|
177
|
-
self._loggers.application.info("Redis connection check successful.")
|
178
|
-
return True
|
179
|
-
except RedisError as e:
|
180
|
-
self._loggers.application.error(f"Redis connection check failed: {e}", exc_info=True)
|
181
|
-
return False
|
182
|
-
|
183
196
|
def _initialize_cloud_storage(self) -> None:
|
184
197
|
environment = (
|
185
198
|
BaseEnums.EnvironmentType.STAGING
|
@@ -37,7 +37,7 @@ maleo_foundation/managers/configuration.py,sha256=Jcm2A_fS-styLEWZurF7nquitnSYuc
|
|
37
37
|
maleo_foundation/managers/credential.py,sha256=i1w9bVozf7FYG8NGfLgJYRdLWBQBf35yyzVOEDgdXSA,3108
|
38
38
|
maleo_foundation/managers/db.py,sha256=y5oP3bTXKeXYKqng-E_HZ-3wC0ZPtl5bls0AEEej6zM,6050
|
39
39
|
maleo_foundation/managers/middleware.py,sha256=ecTNloglV67xoC_hqIEMIxhfQwzXRKHLI3ThJdd-lbY,2480
|
40
|
-
maleo_foundation/managers/service.py,sha256=
|
40
|
+
maleo_foundation/managers/service.py,sha256=b59014syzSrMXzouULxiDpxx5wydqh2gn8SbNezdkX0,11646
|
41
41
|
maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
42
|
maleo_foundation/managers/client/base.py,sha256=o4D_y52Zxl-jOtV59o6ZCJOuS6rlUy7e2x3vs7vB5tk,4314
|
43
43
|
maleo_foundation/managers/client/maleo.py,sha256=fhIXKeIjx0VgS8wjX0Cpk05ZHHRiPvmpUQl0890mZxw,2686
|
@@ -133,7 +133,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
|
|
133
133
|
maleo_foundation/utils/loaders/credential/google.py,sha256=ZglnLdW3lHmaKER4mwGe5N5ERus-bdsamfpwGmQYPIo,6344
|
134
134
|
maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
|
135
135
|
maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
|
136
|
-
maleo_foundation-0.3.
|
137
|
-
maleo_foundation-0.3.
|
138
|
-
maleo_foundation-0.3.
|
139
|
-
maleo_foundation-0.3.
|
136
|
+
maleo_foundation-0.3.32.dist-info/METADATA,sha256=fzndCRGv-11Zpm286yRlAzGOLr7abg5jeobEYkuboyE,3740
|
137
|
+
maleo_foundation-0.3.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
138
|
+
maleo_foundation-0.3.32.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
139
|
+
maleo_foundation-0.3.32.dist-info/RECORD,,
|
File without changes
|
File without changes
|