internal 0.1.32__tar.gz → 0.1.34__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.

Files changed (25) hide show
  1. {internal-0.1.32 → internal-0.1.34}/PKG-INFO +1 -1
  2. {internal-0.1.32 → internal-0.1.34}/pyproject.toml +1 -1
  3. internal-0.1.34/src/internal/exception/internal_exception.py +20 -0
  4. internal-0.1.34/src/internal/http/requests.py +23 -0
  5. internal-0.1.32/src/internal/http/requests.py +0 -12
  6. {internal-0.1.32 → internal-0.1.34}/README.md +0 -0
  7. {internal-0.1.32 → internal-0.1.34}/src/internal/__init__.py +0 -0
  8. {internal-0.1.32 → internal-0.1.34}/src/internal/base_config.py +0 -0
  9. {internal-0.1.32 → internal-0.1.34}/src/internal/base_factory.py +0 -0
  10. {internal-0.1.32 → internal-0.1.34}/src/internal/const.py +0 -0
  11. {internal-0.1.32 → internal-0.1.34}/src/internal/database.py +0 -0
  12. {internal-0.1.32 → internal-0.1.34}/src/internal/exception/__init__.py +0 -0
  13. {internal-0.1.32 → internal-0.1.34}/src/internal/exception/base_exception.py +0 -0
  14. {internal-0.1.32 → internal-0.1.34}/src/internal/ext/__init__.py +0 -0
  15. {internal-0.1.32 → internal-0.1.34}/src/internal/ext/amazon/__init__.py +0 -0
  16. {internal-0.1.32 → internal-0.1.34}/src/internal/ext/amazon/aws/__init__.py +0 -0
  17. {internal-0.1.32 → internal-0.1.34}/src/internal/ext/amazon/aws/const.py +0 -0
  18. {internal-0.1.32 → internal-0.1.34}/src/internal/http/__init__.py +0 -0
  19. {internal-0.1.32 → internal-0.1.34}/src/internal/http/responses.py +0 -0
  20. {internal-0.1.32 → internal-0.1.34}/src/internal/interface/__init__.py +0 -0
  21. {internal-0.1.32 → internal-0.1.34}/src/internal/interface/base_interface.py +0 -0
  22. {internal-0.1.32 → internal-0.1.34}/src/internal/model/__init__.py +0 -0
  23. {internal-0.1.32 → internal-0.1.34}/src/internal/model/base_model.py +0 -0
  24. {internal-0.1.32 → internal-0.1.34}/src/internal/model/operate.py +0 -0
  25. {internal-0.1.32 → internal-0.1.34}/src/internal/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 0.1.32
3
+ Version: 0.1.34
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "internal"
3
- version = "0.1.32"
3
+ version = "0.1.34"
4
4
  description = ""
5
5
  authors = ["Ray <ray@cruisys.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,20 @@
1
+ from fastapi import status
2
+ from .base_exception import InternalBaseException
3
+
4
+
5
+ class BadGatewayException(InternalBaseException):
6
+ code = "error_bad_gateway"
7
+ message = "Bad gateway"
8
+
9
+ def __init__(self, message: str = None, **kwargs):
10
+ _message = message or self.message
11
+ super().__init__(status.HTTP_502_BAD_GATEWAY, self.code, _message, **kwargs)
12
+
13
+
14
+ class GatewayTimeoutException(InternalBaseException):
15
+ code = "error_gateway_timeout"
16
+ message = "Gateway timeout"
17
+
18
+ def __init__(self, message: str = None, **kwargs):
19
+ _message = message or self.message
20
+ super().__init__(status.HTTP_504_GATEWAY_TIMEOUT, self.code, _message, **kwargs)
@@ -0,0 +1,23 @@
1
+ import httpx
2
+
3
+ from fastapi import FastAPI
4
+
5
+ from ..exception.internal_exception import GatewayTimeoutException, BadGatewayException
6
+
7
+
8
+ async def async_request(app: FastAPI, method, url, **kwargs):
9
+ timeout = httpx.Timeout(connect=app.state.config.REQUEST_CONN_TIMEOUT, read=app.state.config.REQUEST_READ_TIMEOUT,
10
+ write=app.state.config.REQUEST_WRITE_TIMEOUT, pool=app.state.config.REQUEST_POOL_TIMEOUT)
11
+
12
+ try:
13
+ async with httpx.AsyncClient(timeout=timeout) as client:
14
+ response = await client.request(method, url, **kwargs)
15
+ return response
16
+ except httpx.TimeoutException as exc:
17
+ app.state.logger.error(
18
+ f"async_request(), TimeoutException, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
19
+ raise GatewayTimeoutException()
20
+ except Exception as exc:
21
+ app.state.logger.error(
22
+ f"async_request(), Exception, exc: {exc}, url: {url}, method: {method}, kwargs: {kwargs}")
23
+ raise BadGatewayException()
@@ -1,12 +0,0 @@
1
- import httpx
2
-
3
- from fastapi import FastAPI
4
-
5
-
6
- async def async_request(app: FastAPI, method, url, **kwargs):
7
- timeout = httpx.Timeout(connect=app.state.config.REQUEST_CONN_TIMEOUT, read=app.state.config.REQUEST_READ_TIMEOUT,
8
- write=app.state.config.REQUEST_WRITE_TIMEOUT, pool=app.state.config.REQUEST_POOL_TIMEOUT)
9
-
10
- async with httpx.AsyncClient(timeout=timeout) as client:
11
- response = await client.request(method, url, **kwargs)
12
- return response
File without changes