internal 1.0.52__tar.gz → 1.0.53__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.
Potentially problematic release.
This version of internal might be problematic. Click here for more details.
- {internal-1.0.52 → internal-1.0.53}/PKG-INFO +1 -1
- {internal-1.0.52 → internal-1.0.53}/pyproject.toml +1 -1
- {internal-1.0.52 → internal-1.0.53}/src/internal/base_factory.py +19 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/http/requests.py +9 -0
- {internal-1.0.52 → internal-1.0.53}/README.md +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/base_config.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/contact_type.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/description_type.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/event_trigger_type.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/lpnr_direction.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/operator_type.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/common_enum/order_type.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/const.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/database.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/exception/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/exception/base_exception.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/exception/internal_exception.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/ext/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/ext/amazon/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/ext/amazon/aws/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/ext/amazon/aws/const.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/http/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/http/responses.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/interface/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/interface/base_interface.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/middleware/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/middleware/log_request.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/model/__init__.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/model/base_model.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/model/operate.py +0 -0
- {internal-1.0.52 → internal-1.0.53}/src/internal/utils.py +0 -0
|
@@ -16,6 +16,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
|
16
16
|
from . import database
|
|
17
17
|
from .const import LOG_FMT, LOG_FMT_NO_DT, LOG_DT_FMT, DEFAULT_LOGGER_NAME
|
|
18
18
|
from .exception.base_exception import InternalBaseException
|
|
19
|
+
from .exception.internal_exception import BadGatewayException, GatewayTimeoutException
|
|
19
20
|
from .ext.amazon import aws
|
|
20
21
|
from .http.requests import async_request
|
|
21
22
|
from .http.responses import async_response
|
|
@@ -125,6 +126,24 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
125
126
|
@app.exception_handler(InternalBaseException)
|
|
126
127
|
async def http_exception_handler(request: Request, exc: InternalBaseException):
|
|
127
128
|
detail = exc.detail
|
|
129
|
+
|
|
130
|
+
if isinstance(exc, BadGatewayException):
|
|
131
|
+
if self.get_app_config().WEBHOOK_BASE_URL:
|
|
132
|
+
message = f"【{self.DEFAULT_APP_NAME}】Bad gateway, request:{request.__dict__}, exc:{exc}"
|
|
133
|
+
payload = {"text": message}
|
|
134
|
+
try:
|
|
135
|
+
await async_request(app, "POST", self.get_app_config().WEBHOOK_BASE_URL, json=payload)
|
|
136
|
+
except Exception as e:
|
|
137
|
+
app.state.logger.warn(f"Notify failure, Exception:{e}")
|
|
138
|
+
elif isinstance(exc, GatewayTimeoutException):
|
|
139
|
+
if self.get_app_config().WEBHOOK_BASE_URL:
|
|
140
|
+
message = f"【{self.DEFAULT_APP_NAME}】Gateway timeout, request:{request.__dict__}, exc:{exc}"
|
|
141
|
+
payload = {"text": message}
|
|
142
|
+
try:
|
|
143
|
+
await async_request(app, "POST", self.get_app_config().WEBHOOK_BASE_URL, json=payload)
|
|
144
|
+
except Exception as e:
|
|
145
|
+
app.state.logger.warn(f"Notify failure, Exception:{e}")
|
|
146
|
+
|
|
128
147
|
return await async_response(data=detail.get("data"), code=detail.get("code"), message=detail.get("message"),
|
|
129
148
|
status_code=exc.status_code)
|
|
130
149
|
|
|
@@ -36,3 +36,12 @@ async def async_request(app: FastAPI, method, url, current_user: dict = None, **
|
|
|
36
36
|
app.state.logger.warn(
|
|
37
37
|
f"async_request(), Exception, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
|
|
38
38
|
raise BadGatewayException(str(exc))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async def send_webhook_message(app: FastAPI, message: str):
|
|
42
|
+
if app.state.config.WEBHOOK_BASE_URL:
|
|
43
|
+
payload = {"text": message}
|
|
44
|
+
try:
|
|
45
|
+
await async_request(app, "POST", app.state.config.WEBHOOK_BASE_URL, json=payload)
|
|
46
|
+
except Exception as e:
|
|
47
|
+
app.state.logger.warn(f"Notify failure, Exception:{e}")
|
|
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
|
|
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
|