-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b17aa5a
commit 44251c4
Showing
33 changed files
with
1,064 additions
and
1,199 deletions.
There are no files selected for viewing
1,121 changes: 0 additions & 1,121 deletions
1,121
backend/alembic/versions/2024_07_04_2338-c09c3268e2b9_init_db.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import logging | ||
from collections.abc import Callable, Coroutine | ||
from logging.config import dictConfig | ||
from typing import Any, TypeVar | ||
|
||
from anyio.from_thread import start_blocking_portal | ||
from celery import Celery | ||
from celery.signals import setup_logging | ||
|
||
from src.core.config import settings | ||
from src.core.utils.loggers import LOGGING | ||
|
||
_R = TypeVar("_R") | ||
|
||
celery_app = Celery( | ||
__name__, | ||
backend=settings.CELERY_BACKEND_URL, | ||
broker=settings.CELERY_BROKER_URL, | ||
broker_connection_retry_on_startup=True, | ||
task_acks_late=True, | ||
task_reject_on_worker_lost=True, | ||
worker_prefetch_multiplier=1, | ||
worker_max_tasks_per_child=1, | ||
task_track_started=True, | ||
task_serializer="json", | ||
result_serializer="json", | ||
result_persistence=True, | ||
imports=(), | ||
) | ||
|
||
|
||
def async_task(func: Callable[..., Coroutine[Any, Any, _R]]) -> _R: | ||
def wrapper(*args: Any) -> _R: | ||
with start_blocking_portal() as portal: | ||
return portal.call(func, *args) | ||
|
||
return wrapper # type: ignore # noqa: PGH003 | ||
|
||
|
||
@setup_logging.connect | ||
def _setup_logging(**kwargs: Any) -> None: # noqa: ARG001 | ||
dictConfig(LOGGING) | ||
logging.getLogger("child").propagate = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from enum import StrEnum | ||
|
||
|
||
class AlertStatusType(StrEnum): | ||
FIRERING = "FIRERING" | ||
RESOLVED = "RESOLVED" | ||
|
||
|
||
class AlertSeverityType(StrEnum): | ||
P4 = "P4" | ||
P3 = "P3" | ||
P2 = "P2" | ||
P1 = "P1" | ||
P0 = "P0" | ||
|
||
|
||
class NotificationChannelType(StrEnum): | ||
WEBHOOK = "WEBHOOK" | ||
FEISHU_PRIVATE = "FEISHU_PRIVATE" | ||
FEISHU_GROUP = "FEISHU_GROUP" | ||
DINGTALK_PRIVATE = "DINGTALK_PRIVATE" | ||
DINGTALK_GROUP = "DINGTALK_GROUP" | ||
WECHAT_PRIVATE = "WECHAT_PRIVATE" | ||
WECHAT_GROUP = "WECHAT_GROUP" | ||
SLACK_PRIVATE = "SLACK_PRIVATE" | ||
SLACK_GROUP = "SLACK_GROUP" | ||
EMAIL = "EMAIL" | ||
|
||
|
||
class NotificationResultType(StrEnum): | ||
SUCCESS = "SUCCESS" | ||
FAIL = "FAIL" | ||
UNKNOWN = "UNKNOWN" | ||
|
||
|
||
class EventOperationType(StrEnum): | ||
ACKNOWLEDGE = "ACKNOWLEDGE" | ||
UNACKNOWLEDGE = "UNACKNOWLEDGE" | ||
CLOSE = "CLOSE" | ||
COMMENT = "COMMENT" | ||
ASSIGN = "ASSIGN" | ||
INHIBIT = "INHIBIT" |
Oops, something went wrong.