-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
84 changed files
with
3,642 additions
and
51 deletions.
There are no files selected for viewing
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,2 @@ | ||
include makefiles/const.mk | ||
include makefiles/build-image.mk |
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 |
---|---|---|
@@ -1,2 +1,86 @@ | ||
# template-project | ||
This is the template project for initializing other LTC projects. | ||
# KDP Catalog Manager | ||
|
||
## 项目描述 | ||
|
||
### 项目概述 | ||
KDP Catalog Manager是一套大数据应用管理平台。基于应用功能进行分类查看、管理,降低应用管理的复杂度,从而使大数据管理人员更专注于数据的处理 | ||
|
||
### 核心技术架构 | ||
![kdp-catalog-manager](kdp-catalog-manager.png) | ||
|
||
|
||
|
||
### 功能模块描述 | ||
|
||
#### api | ||
* view | ||
定义 Restful API 并对用户输入参数执行基本验证及结果输出 | ||
|
||
#### Domain | ||
* service | ||
业务逻辑 | ||
* format | ||
数据转换层,用于缓存数据与业务数据转换 | ||
* model | ||
数据模型实体 | ||
|
||
|
||
##### Modules | ||
* cache | ||
数据存储层,静态数据存储于缓存中 | ||
* requests | ||
外部数据调用,调用外部服务获取数据 | ||
|
||
|
||
## 目录结构 | ||
```shell | ||
├── CODEOWNERS | ||
├── README.md | ||
└── kdp_catalog_manager | ||
├── api | ||
├── common | ||
├── config | ||
├── main.py # 服务启动程序 | ||
├── requirements.txt | ||
├── test_main.py | ||
├── domain | ||
├── modules | ||
└── utils | ||
``` | ||
|
||
## 启动方式 | ||
### 开发环境搭建 | ||
* 使用python3.10+ | ||
|
||
1. 克隆代码至本地 | ||
```shell | ||
git clone xxx && cd kdp-catalog-manager | ||
``` | ||
|
||
2. 使用虚拟环境 | ||
```shell | ||
#安装virtualenv | ||
pip install virtualenv | ||
virtualenv -p /usr/local/bin/python3 venv | ||
# 激活虚拟环境 | ||
source ./venv/bin/activate | ||
|
||
# 关闭虚拟环境 | ||
deactivate | ||
``` | ||
|
||
3. 安装依赖 | ||
```shell | ||
pip install -r docker/python/requirements.txt | ||
``` | ||
|
||
4. 服务启动 | ||
```shell | ||
cd ~/kdp-catalog-manager \ | ||
&& export PYTHONPATH=$PYTHONPATH:$(pwd) | ||
python kdp_catalog_manager/main.py | ||
|
||
``` | ||
|
||
### API 手册 | ||
* 启动服务后通过 http://127.0.0.1:8000/docs 查看提供的接口列表 |
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,2 @@ | ||
[global] | ||
index-url = https://nx.linktimecloud.com/repository/pypi-group/simple/ |
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,2 @@ | ||
[global] | ||
index-url = https://pypi.douban.com/simple/ |
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,8 @@ | ||
fastapi[all]==0.110.0 | ||
uvicorn[standard]==0.27.1 | ||
cachelib==0.12.0 | ||
concurrent-log-handler==0.9.25 | ||
cachelib==0.12.0 | ||
markdown==3.5.2 | ||
prometheus-fastapi-instrumentator==6.1.0 | ||
gunicorn==21.2.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,18 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
from fastapi import APIRouter | ||
|
||
from kdp_catalog_manager.api.api_v1.endpoints import catalog | ||
from kdp_catalog_manager.api.api_v1.endpoints import catalog_app_form | ||
from kdp_catalog_manager.api.api_v1.endpoints import catalog_app_runtime | ||
|
||
api_router = APIRouter() | ||
|
||
# 分组路由 | ||
api_router.include_router(catalog.router, tags=["Catalog"]) | ||
api_router.include_router( | ||
catalog_app_form.router, tags=["CatalogAppForm"] | ||
) | ||
api_router.include_router( | ||
catalog_app_runtime.router, tags=["CatalogRuntime"] | ||
) |
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,2 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- |
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,100 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
from typing import Annotated | ||
|
||
from fastapi import APIRouter, Path, Response, status, Header | ||
from fastapi.responses import HTMLResponse | ||
|
||
from kdp_catalog_manager.common.constants import CATALOG_DESC, \ | ||
NOT_FOUND_README_HTML | ||
from kdp_catalog_manager.config.base_config import DEFAULT_LANG, SUPPORT_LANG | ||
from kdp_catalog_manager.domain.model.catalog import CatalogList, \ | ||
CatalogDataOut | ||
from kdp_catalog_manager.domain.service.catalog import CatalogController | ||
from kdp_catalog_manager.exceptions.exception import KdpCatalogManagerError, \ | ||
FileNotExistsError, LangNotSupport | ||
from kdp_catalog_manager.utils.format_return import FormatReturn | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/catalogs", | ||
response_model=CatalogList, | ||
summary="获取应用目录列表", | ||
description="获取应用目录列表操作") | ||
async def read_catalogs( | ||
accept_language: Annotated[str, Header(description="请求语言类型")] = DEFAULT_LANG | ||
): | ||
"""获取catalog 列表""" | ||
try: | ||
if accept_language not in SUPPORT_LANG: | ||
raise LangNotSupport( | ||
f"Header Accept-Language is:{accept_language}, " | ||
f"not in {SUPPORT_LANG}") | ||
data = CatalogController(lang=accept_language).get_catalogs() | ||
rtn = FormatReturn().format_return_json( | ||
data, msg="get catalogs data success") | ||
except KdpCatalogManagerError as error: | ||
error_info = FormatReturn().format_error_info( | ||
error.error_name, | ||
error.error_details, | ||
error_msg=error.error_cname | ||
) | ||
rtn = FormatReturn().format_return_json( | ||
[], status=1, msg=error.error_cname, error_info=error_info) | ||
return rtn | ||
|
||
|
||
@router.get("/catalogs/{catalog}", | ||
response_model=CatalogDataOut, | ||
summary="获取应用目录信息", | ||
description="获取某个应用目录信息操作") | ||
async def read_catalog( | ||
catalog: Annotated[str, Path(description=CATALOG_DESC)], | ||
accept_language: Annotated[str, Header(description="请求语言类型")] = DEFAULT_LANG | ||
): | ||
"""获取catalog 信息""" | ||
try: | ||
if accept_language not in SUPPORT_LANG: | ||
raise LangNotSupport( | ||
f"Header Accept-Language is:{accept_language}, " | ||
f"not in {SUPPORT_LANG}") | ||
data = CatalogController( | ||
catalog=catalog, lang=accept_language).get_catalog() | ||
rtn = FormatReturn().format_return_json( | ||
data, msg="get catalogs data success") | ||
except KdpCatalogManagerError as error: | ||
error_info = FormatReturn().format_error_info( | ||
error.error_name, | ||
error.error_details, | ||
error_msg=error.error_cname | ||
) | ||
rtn = FormatReturn().format_return_json( | ||
{}, status=1, msg=error.error_cname, error_info=error_info) | ||
return rtn | ||
|
||
|
||
@router.get("/catalogs/{catalog}/readme", | ||
response_class=HTMLResponse, | ||
summary="获取应用目录说明", | ||
description="获取某个应用目录说明操作") | ||
async def read_catalog_readme( | ||
response: Response, | ||
catalog: Annotated[str, Path(description=CATALOG_DESC)], | ||
accept_language: Annotated[str, Header(description="请求语言类型")] = DEFAULT_LANG | ||
): | ||
"""获取catalog 说明""" | ||
try: | ||
if accept_language not in SUPPORT_LANG: | ||
raise LangNotSupport( | ||
f"Header Accept-Language is:{accept_language}, " | ||
f"not in {SUPPORT_LANG}") | ||
rtn = CatalogController( | ||
catalog, lang=accept_language).get_catalog_readme() | ||
except FileNotExistsError: | ||
response.status_code = status.HTTP_404_NOT_FOUND | ||
rtn = NOT_FOUND_README_HTML | ||
except LangNotSupport: | ||
response.status_code = status.HTTP_400_BAD_REQUEST | ||
rtn = "语言不支持:Header Accept-Language is:ens, not in ['zh', 'en']" | ||
return rtn |
Oops, something went wrong.