algo-backend-framework 0.0.2__tar.gz → 0.0.4__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.
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/PKG-INFO +1 -1
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/__init__.py +7 -1
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/exception.py +31 -3
- algo_backend_framework-0.0.4/algo_backend/handler/__init__.py +3 -0
- algo_backend_framework-0.0.4/algo_backend/handler/exception_to_vo.py +25 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/default_app_generator.py +7 -1
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend_framework.egg-info/PKG-INFO +1 -1
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend_framework.egg-info/SOURCES.txt +1 -1
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/pyproject.toml +1 -1
- algo_backend_framework-0.0.2/algo_backend/handler/__init__.py +0 -3
- algo_backend_framework-0.0.2/algo_backend/handler/exception_to_vo.py +0 -37
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/README.md +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/basic_config.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/loguru_config.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/error_code_manage.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/status_code.py +0 -0
- /algo_backend_framework-0.0.2/algo_backend/handler/operation_handler.py → /algo_backend_framework-0.0.4/algo_backend/handler/simple_handler.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/common.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/http.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/validate.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/common.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_clean.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_setup.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_starter.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/patch_logging.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/nblog/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/collector/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/collector/common.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/collector/gc_metrics.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/collector/schedule_monitor.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/collector/system_metrics.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/http_metrics.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/prometheus_context.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/time_cost_metrics.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/cors.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/metrics.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/schema/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/schema/vo.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/default_service_starter.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/event_list.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/utils/__init__.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/utils/meta_class.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/utils/utils.py +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend_framework.egg-info/dependency_links.txt +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend_framework.egg-info/requires.txt +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend_framework.egg-info/top_level.txt +0 -0
- {algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/setup.cfg +0 -0
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/__init__.py
RENAMED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
from .error_code_manage import ApiErrorCodeManage, BasicCodeManage
|
|
2
|
-
from .exception import
|
|
2
|
+
from .exception import (
|
|
3
|
+
BasicApiInnerException,
|
|
4
|
+
BasicCommonException,
|
|
5
|
+
BasicException,
|
|
6
|
+
transfer_exception,
|
|
7
|
+
)
|
|
3
8
|
from .status_code import (
|
|
4
9
|
BasicApiId,
|
|
5
10
|
BasicApiInnerErrorCode,
|
|
@@ -19,4 +24,5 @@ __all__ = [
|
|
|
19
24
|
"BasicCommonException",
|
|
20
25
|
"DefaultApiErrorCode",
|
|
21
26
|
"BasicException",
|
|
27
|
+
"transfer_exception",
|
|
22
28
|
]
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/exception.py
RENAMED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
from typing import TypeVar
|
|
1
|
+
from typing import Optional, TypeVar
|
|
2
2
|
|
|
3
|
-
from .status_code import
|
|
3
|
+
from .status_code import (
|
|
4
|
+
BasicApiId,
|
|
5
|
+
BasicApiInnerErrorCode,
|
|
6
|
+
BasicStatusCode,
|
|
7
|
+
CommonStatusCode,
|
|
8
|
+
add_service_prefix,
|
|
9
|
+
)
|
|
4
10
|
|
|
5
11
|
|
|
6
12
|
class BasicException(Exception):
|
|
@@ -35,8 +41,30 @@ class BasicApiInnerException(BasicException):
|
|
|
35
41
|
def __init__(self, status_code: ET, **kwargs):
|
|
36
42
|
super().__init__(code=status_code.code, msg=status_code.msg.format(**kwargs))
|
|
37
43
|
|
|
38
|
-
def
|
|
44
|
+
def standardize(self, api_id: BasicApiId) -> "BasicApiInnerException":
|
|
45
|
+
"""
|
|
46
|
+
生8位错误码
|
|
47
|
+
:param api_id:
|
|
48
|
+
:return:
|
|
49
|
+
"""
|
|
39
50
|
self.code = BasicApiInnerErrorCode.gen_standard_code(
|
|
40
51
|
api_id=api_id, inner_error_code=self.code
|
|
41
52
|
)
|
|
53
|
+
# 增加两位应用码
|
|
54
|
+
self.code = add_service_prefix(self.code)
|
|
42
55
|
return self
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def transfer_exception(
|
|
59
|
+
e: Exception,
|
|
60
|
+
api_name: Optional[str] = None,
|
|
61
|
+
request_id: Optional[str] = None,
|
|
62
|
+
api_id: Optional[BasicApiId] = None,
|
|
63
|
+
) -> BasicException:
|
|
64
|
+
_params = dict(api_name=api_name, request_id=request_id)
|
|
65
|
+
if isinstance(e, BasicCommonException):
|
|
66
|
+
return e
|
|
67
|
+
elif isinstance(e, BasicApiInnerException):
|
|
68
|
+
return e.standardize(api_id=api_id)
|
|
69
|
+
else:
|
|
70
|
+
return BasicCommonException(CommonStatusCode.UNKNOWN_ERROR, msg=str(e))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
from algo_backend.exception import BasicApiId, transfer_exception
|
|
5
|
+
from algo_backend.schema import AbstractRespVo
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def gen_vo_from_exception(
|
|
11
|
+
vo_cls: type(AbstractRespVo),
|
|
12
|
+
e: Exception,
|
|
13
|
+
api_name: Optional[str] = None,
|
|
14
|
+
request_id: Optional[str] = None,
|
|
15
|
+
api_id: Optional[BasicApiId] = None,
|
|
16
|
+
) -> AbstractRespVo:
|
|
17
|
+
"""
|
|
18
|
+
将异常转换为vo
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
_params = dict(api_name=api_name, request_id=request_id)
|
|
22
|
+
return vo_cls.from_exception(
|
|
23
|
+
transfer_exception(e, api_name=api_name, request_id=request_id, api_id=api_id),
|
|
24
|
+
**_params,
|
|
25
|
+
)
|
|
@@ -87,7 +87,7 @@ class DefaultAlgoAppGenerator:
|
|
|
87
87
|
"""
|
|
88
88
|
初始化开始事件
|
|
89
89
|
"""
|
|
90
|
-
self.start_event_list.add(self.
|
|
90
|
+
self.start_event_list.add(self.__set_up_logger)
|
|
91
91
|
# 启动系统指标、gc指标的定时采集写入以供多进程时的汇总
|
|
92
92
|
self.start_event_list.add(MetricsScheduleMonitor().run_monitor)
|
|
93
93
|
# 接口计时器和客户端解释器的初始化
|
|
@@ -96,6 +96,12 @@ class DefaultAlgoAppGenerator:
|
|
|
96
96
|
for event in custom_event or []:
|
|
97
97
|
self.start_event_list.add(event)
|
|
98
98
|
|
|
99
|
+
def __set_up_logger(self):
|
|
100
|
+
"""
|
|
101
|
+
初始化日志
|
|
102
|
+
"""
|
|
103
|
+
self.log_starter.setup_log()
|
|
104
|
+
|
|
99
105
|
def init_end_event(self, custom_event):
|
|
100
106
|
"""
|
|
101
107
|
初始化结束事件
|
|
@@ -10,7 +10,7 @@ algo_backend/exception/exception.py
|
|
|
10
10
|
algo_backend/exception/status_code.py
|
|
11
11
|
algo_backend/handler/__init__.py
|
|
12
12
|
algo_backend/handler/exception_to_vo.py
|
|
13
|
-
algo_backend/handler/
|
|
13
|
+
algo_backend/handler/simple_handler.py
|
|
14
14
|
algo_backend/intercept/__init__.py
|
|
15
15
|
algo_backend/intercept/common.py
|
|
16
16
|
algo_backend/intercept/http.py
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
from algo_backend.exception import (
|
|
5
|
-
BasicApiId,
|
|
6
|
-
BasicApiInnerException,
|
|
7
|
-
BasicCommonException,
|
|
8
|
-
CommonStatusCode,
|
|
9
|
-
)
|
|
10
|
-
from algo_backend.schema import AbstractRespVo
|
|
11
|
-
|
|
12
|
-
logger = logging.getLogger(__name__)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def gen_vo_from_exception(
|
|
16
|
-
vo_cls: type(AbstractRespVo),
|
|
17
|
-
e: Exception,
|
|
18
|
-
api_name: Optional[str] = None,
|
|
19
|
-
request_id: Optional[str] = None,
|
|
20
|
-
api_id: Optional[BasicApiId] = None,
|
|
21
|
-
) -> AbstractRespVo:
|
|
22
|
-
"""
|
|
23
|
-
将异常转换为vo
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
_params = dict(api_name=api_name, request_id=request_id)
|
|
27
|
-
if isinstance(e, BasicCommonException):
|
|
28
|
-
vo = vo_cls.from_exception(e, **_params)
|
|
29
|
-
elif isinstance(e, BasicApiInnerException):
|
|
30
|
-
vo = vo_cls.from_exception(e.add_api_id(api_id=api_id), **_params)
|
|
31
|
-
else:
|
|
32
|
-
vo = vo_cls.from_exception(
|
|
33
|
-
BasicCommonException(CommonStatusCode.UNKNOWN_ERROR, msg=str(e)),
|
|
34
|
-
**_params,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
return vo
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/basic_config.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/config/loguru_config.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/exception/status_code.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/common.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/http.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/intercept/validate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_clean.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_setup.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/loguru/log_starter.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/log/nblog/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/metrics/http_metrics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/cors.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/middleware/metrics.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/schema/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/starter/event_list.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/utils/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.2 → algo_backend_framework-0.0.4}/algo_backend/utils/meta_class.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|