-
Notifications
You must be signed in to change notification settings - Fork 5
Added health_db_adapter endpoint #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e528204
to
97fe70a
Compare
core/db_adapter/aioredis_adapter.py
Outdated
return self.db_adapter._redis.ping() | ||
except Exception as _: | ||
log("AIORedisAdapter is not alive", level="INFO") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return |
Python по умолчанию так делает окончанию функции
|
||
async def is_alive(self): | ||
try: | ||
await self.db_adapter._sentinel.sentinels() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bdb3a25
to
bd21052
Compare
status, reason, answer = 200, "OK", "ok" | ||
is_alive = await self.db_adapter.is_alive() | ||
if not is_alive: | ||
status, reason, answer = 500, "ERROR", "db adapter connection error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Давай прокинем в reason комментарий из Exception'а из is_alive?
core/db_adapter/aioredis_adapter.py
Outdated
@@ -70,3 +70,9 @@ async def _path_exists(self, path): | |||
|
|||
async def _on_prepare(self): | |||
pass | |||
|
|||
async def is_alive(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async def is_alive(self): | |
async def is_alive(self) -> bool | None: |
Давай аннотациями приправим
3bf7d54
to
e69fa04
Compare
core/db_adapter/ignite_adapter.py
Outdated
try: | ||
await self.connect() | ||
return True | ||
except Exception as _: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except Exception as _: | |
except Exception: |
402e40f
to
cc24cc5
Compare
core/db_adapter/aioredis_adapter.py
Outdated
@@ -70,3 +70,9 @@ async def _path_exists(self, path): | |||
|
|||
async def _on_prepare(self): | |||
pass | |||
|
|||
async def is_alive(self) -> bool | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async def is_alive(self) -> bool | None: | |
async def is_alive(self) -> Optional[bool]: |
+ импорт
Это для поддержки Python 3.9
/health_db_adapter - This endpoint returns 200 if the service is available and it can connect to db_adapter (e.g., Ignite) and 500 if the service is unavailable or cannot connect to db_adapter