aury-boot 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl
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.
- aury/boot/__init__.py +66 -0
- aury/boot/_version.py +2 -2
- aury/boot/application/__init__.py +120 -0
- aury/boot/application/app/__init__.py +39 -0
- aury/boot/application/app/base.py +511 -0
- aury/boot/application/app/components.py +434 -0
- aury/boot/application/app/middlewares.py +101 -0
- aury/boot/application/config/__init__.py +44 -0
- aury/boot/application/config/settings.py +663 -0
- aury/boot/application/constants/__init__.py +19 -0
- aury/boot/application/constants/components.py +50 -0
- aury/boot/application/constants/scheduler.py +28 -0
- aury/boot/application/constants/service.py +29 -0
- aury/boot/application/errors/__init__.py +55 -0
- aury/boot/application/errors/chain.py +80 -0
- aury/boot/application/errors/codes.py +67 -0
- aury/boot/application/errors/exceptions.py +238 -0
- aury/boot/application/errors/handlers.py +320 -0
- aury/boot/application/errors/response.py +120 -0
- aury/boot/application/interfaces/__init__.py +76 -0
- aury/boot/application/interfaces/egress.py +224 -0
- aury/boot/application/interfaces/ingress.py +98 -0
- aury/boot/application/middleware/__init__.py +22 -0
- aury/boot/application/middleware/logging.py +451 -0
- aury/boot/application/migrations/__init__.py +13 -0
- aury/boot/application/migrations/manager.py +685 -0
- aury/boot/application/migrations/setup.py +237 -0
- aury/boot/application/rpc/__init__.py +63 -0
- aury/boot/application/rpc/base.py +108 -0
- aury/boot/application/rpc/client.py +294 -0
- aury/boot/application/rpc/discovery.py +218 -0
- aury/boot/application/scheduler/__init__.py +13 -0
- aury/boot/application/scheduler/runner.py +123 -0
- aury/boot/application/server/__init__.py +296 -0
- aury/boot/commands/__init__.py +30 -0
- aury/boot/commands/add.py +76 -0
- aury/boot/commands/app.py +105 -0
- aury/boot/commands/config.py +177 -0
- aury/boot/commands/docker.py +367 -0
- aury/boot/commands/docs.py +284 -0
- aury/boot/commands/generate.py +1277 -0
- aury/boot/commands/init.py +890 -0
- aury/boot/commands/migrate/__init__.py +37 -0
- aury/boot/commands/migrate/app.py +54 -0
- aury/boot/commands/migrate/commands.py +303 -0
- aury/boot/commands/scheduler.py +124 -0
- aury/boot/commands/server/__init__.py +21 -0
- aury/boot/commands/server/app.py +541 -0
- aury/boot/commands/templates/generate/api.py.tpl +105 -0
- aury/boot/commands/templates/generate/model.py.tpl +17 -0
- aury/boot/commands/templates/generate/repository.py.tpl +19 -0
- aury/boot/commands/templates/generate/schema.py.tpl +29 -0
- aury/boot/commands/templates/generate/service.py.tpl +48 -0
- aury/boot/commands/templates/project/CLI.md.tpl +92 -0
- aury/boot/commands/templates/project/DEVELOPMENT.md.tpl +1397 -0
- aury/boot/commands/templates/project/README.md.tpl +111 -0
- aury/boot/commands/templates/project/admin_console_init.py.tpl +50 -0
- aury/boot/commands/templates/project/config.py.tpl +30 -0
- aury/boot/commands/templates/project/conftest.py.tpl +26 -0
- aury/boot/commands/templates/project/env.example.tpl +213 -0
- aury/boot/commands/templates/project/gitignore.tpl +128 -0
- aury/boot/commands/templates/project/main.py.tpl +41 -0
- aury/boot/commands/templates/project/modules/api.py.tpl +19 -0
- aury/boot/commands/templates/project/modules/exceptions.py.tpl +84 -0
- aury/boot/commands/templates/project/modules/schedules.py.tpl +18 -0
- aury/boot/commands/templates/project/modules/tasks.py.tpl +20 -0
- aury/boot/commands/worker.py +143 -0
- aury/boot/common/__init__.py +35 -0
- aury/boot/common/exceptions/__init__.py +114 -0
- aury/boot/common/i18n/__init__.py +16 -0
- aury/boot/common/i18n/translator.py +272 -0
- aury/boot/common/logging/__init__.py +716 -0
- aury/boot/contrib/__init__.py +10 -0
- aury/boot/contrib/admin_console/__init__.py +18 -0
- aury/boot/contrib/admin_console/auth.py +137 -0
- aury/boot/contrib/admin_console/discovery.py +69 -0
- aury/boot/contrib/admin_console/install.py +172 -0
- aury/boot/contrib/admin_console/utils.py +44 -0
- aury/boot/domain/__init__.py +79 -0
- aury/boot/domain/exceptions/__init__.py +132 -0
- aury/boot/domain/models/__init__.py +51 -0
- aury/boot/domain/models/base.py +69 -0
- aury/boot/domain/models/mixins.py +135 -0
- aury/boot/domain/models/models.py +96 -0
- aury/boot/domain/pagination/__init__.py +279 -0
- aury/boot/domain/repository/__init__.py +23 -0
- aury/boot/domain/repository/impl.py +423 -0
- aury/boot/domain/repository/interceptors.py +47 -0
- aury/boot/domain/repository/interface.py +106 -0
- aury/boot/domain/repository/query_builder.py +348 -0
- aury/boot/domain/service/__init__.py +11 -0
- aury/boot/domain/service/base.py +73 -0
- aury/boot/domain/transaction/__init__.py +404 -0
- aury/boot/infrastructure/__init__.py +104 -0
- aury/boot/infrastructure/cache/__init__.py +31 -0
- aury/boot/infrastructure/cache/backends.py +348 -0
- aury/boot/infrastructure/cache/base.py +68 -0
- aury/boot/infrastructure/cache/exceptions.py +37 -0
- aury/boot/infrastructure/cache/factory.py +94 -0
- aury/boot/infrastructure/cache/manager.py +274 -0
- aury/boot/infrastructure/database/__init__.py +39 -0
- aury/boot/infrastructure/database/config.py +71 -0
- aury/boot/infrastructure/database/exceptions.py +44 -0
- aury/boot/infrastructure/database/manager.py +317 -0
- aury/boot/infrastructure/database/query_tools/__init__.py +164 -0
- aury/boot/infrastructure/database/strategies/__init__.py +198 -0
- aury/boot/infrastructure/di/__init__.py +15 -0
- aury/boot/infrastructure/di/container.py +393 -0
- aury/boot/infrastructure/events/__init__.py +33 -0
- aury/boot/infrastructure/events/bus.py +362 -0
- aury/boot/infrastructure/events/config.py +52 -0
- aury/boot/infrastructure/events/consumer.py +134 -0
- aury/boot/infrastructure/events/middleware.py +51 -0
- aury/boot/infrastructure/events/models.py +63 -0
- aury/boot/infrastructure/monitoring/__init__.py +529 -0
- aury/boot/infrastructure/scheduler/__init__.py +19 -0
- aury/boot/infrastructure/scheduler/exceptions.py +37 -0
- aury/boot/infrastructure/scheduler/manager.py +478 -0
- aury/boot/infrastructure/storage/__init__.py +38 -0
- aury/boot/infrastructure/storage/base.py +164 -0
- aury/boot/infrastructure/storage/exceptions.py +37 -0
- aury/boot/infrastructure/storage/factory.py +88 -0
- aury/boot/infrastructure/tasks/__init__.py +24 -0
- aury/boot/infrastructure/tasks/config.py +45 -0
- aury/boot/infrastructure/tasks/constants.py +37 -0
- aury/boot/infrastructure/tasks/exceptions.py +37 -0
- aury/boot/infrastructure/tasks/manager.py +490 -0
- aury/boot/testing/__init__.py +24 -0
- aury/boot/testing/base.py +122 -0
- aury/boot/testing/client.py +163 -0
- aury/boot/testing/factory.py +154 -0
- aury/boot/toolkit/__init__.py +21 -0
- aury/boot/toolkit/http/__init__.py +367 -0
- {aury_boot-0.0.2.dist-info → aury_boot-0.0.3.dist-info}/METADATA +3 -2
- aury_boot-0.0.3.dist-info/RECORD +137 -0
- aury_boot-0.0.2.dist-info/RECORD +0 -5
- {aury_boot-0.0.2.dist-info → aury_boot-0.0.3.dist-info}/WHEEL +0 -0
- {aury_boot-0.0.2.dist-info → aury_boot-0.0.3.dist-info}/entry_points.txt +0 -0
aury/boot/__init__.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Aury Boot - 核心基础架构工具包。
|
|
2
|
+
|
|
3
|
+
提供数据库、缓存、认证等核心基础设施功能。
|
|
4
|
+
|
|
5
|
+
模块结构:
|
|
6
|
+
- common: 最基础层(异常基类、日志系统、国际化)
|
|
7
|
+
- domain: 领域层(业务模型、仓储接口、服务基类、分页、事务管理)
|
|
8
|
+
- infrastructure: 基础设施层(外部依赖的实现:数据库、缓存、存储、调度器等)
|
|
9
|
+
- application: 应用层(配置管理、RPC通信、依赖注入、事务管理、事件系统、迁移管理、API接口)
|
|
10
|
+
- toolkit: 工具包(通用工具函数)
|
|
11
|
+
- testing: 测试框架(测试基类、测试客户端、数据工厂)
|
|
12
|
+
|
|
13
|
+
使用方式:
|
|
14
|
+
from aury.boot import application
|
|
15
|
+
from aury.boot.domain.models import Model
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import importlib
|
|
21
|
+
from typing import TYPE_CHECKING
|
|
22
|
+
|
|
23
|
+
# 版本号由 hatch-vcs 自动生成
|
|
24
|
+
try:
|
|
25
|
+
from ._version import __version__
|
|
26
|
+
except ImportError:
|
|
27
|
+
__version__ = "0.0.0.dev0"
|
|
28
|
+
|
|
29
|
+
# 延迟导入:子模块仅在被访问时才加载
|
|
30
|
+
_SUBMODULES = {
|
|
31
|
+
"application",
|
|
32
|
+
"common",
|
|
33
|
+
"domain",
|
|
34
|
+
"infrastructure",
|
|
35
|
+
"toolkit",
|
|
36
|
+
"testing",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __getattr__(name: str):
|
|
41
|
+
"""延迟导入子模块。"""
|
|
42
|
+
if name in _SUBMODULES:
|
|
43
|
+
try:
|
|
44
|
+
return importlib.import_module(f".{name}", __name__)
|
|
45
|
+
except ImportError:
|
|
46
|
+
if name == "testing":
|
|
47
|
+
# testing 模块可能在生产环境不可用
|
|
48
|
+
return None
|
|
49
|
+
raise
|
|
50
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def __dir__():
|
|
54
|
+
"""返回可用属性列表。"""
|
|
55
|
+
return list(_SUBMODULES) + ["__version__"]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"__version__",
|
|
60
|
+
"application",
|
|
61
|
+
"common",
|
|
62
|
+
"domain",
|
|
63
|
+
"infrastructure",
|
|
64
|
+
"toolkit",
|
|
65
|
+
"testing",
|
|
66
|
+
]
|
aury/boot/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 0,
|
|
31
|
+
__version__ = version = '0.0.3'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 3)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""应用层模块。
|
|
2
|
+
|
|
3
|
+
提供用例编排、配置管理、RPC通信、依赖注入、事务管理和事件系统。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# 事件系统(从 infrastructure 导入 - Event 定义在最底层)
|
|
7
|
+
# 事务管理(从 domain 导入)
|
|
8
|
+
from aury.boot.domain.transaction import (
|
|
9
|
+
TransactionManager,
|
|
10
|
+
TransactionRequiredError,
|
|
11
|
+
ensure_transaction,
|
|
12
|
+
transactional,
|
|
13
|
+
transactional_context,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# 依赖注入容器(从 infrastructure 导入)
|
|
17
|
+
from aury.boot.infrastructure.di import Container, Lifetime, Scope, ServiceDescriptor
|
|
18
|
+
from aury.boot.infrastructure.events import (
|
|
19
|
+
Event,
|
|
20
|
+
EventBus,
|
|
21
|
+
EventConsumer,
|
|
22
|
+
EventLoggingMiddleware,
|
|
23
|
+
EventMiddleware,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from . import interfaces, rpc
|
|
27
|
+
|
|
28
|
+
# 应用框架、中间件和组件系统
|
|
29
|
+
from .app import (
|
|
30
|
+
CacheComponent,
|
|
31
|
+
Component,
|
|
32
|
+
CORSMiddleware,
|
|
33
|
+
DatabaseComponent,
|
|
34
|
+
FoundationApp,
|
|
35
|
+
Middleware,
|
|
36
|
+
MigrationComponent,
|
|
37
|
+
RequestLoggingMiddleware,
|
|
38
|
+
SchedulerComponent,
|
|
39
|
+
TaskComponent,
|
|
40
|
+
)
|
|
41
|
+
from .config import (
|
|
42
|
+
BaseConfig,
|
|
43
|
+
CacheSettings,
|
|
44
|
+
CORSSettings,
|
|
45
|
+
LogSettings,
|
|
46
|
+
ServerSettings,
|
|
47
|
+
)
|
|
48
|
+
from .constants import ComponentName, MiddlewareName, SchedulerMode, ServiceType
|
|
49
|
+
|
|
50
|
+
# HTTP 中间件装饰器
|
|
51
|
+
from .middleware import (
|
|
52
|
+
log_request,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# 迁移管理
|
|
56
|
+
from .migrations import MigrationManager
|
|
57
|
+
|
|
58
|
+
# 调度器启动器
|
|
59
|
+
from .scheduler import run_scheduler, run_scheduler_sync
|
|
60
|
+
|
|
61
|
+
# 服务器集成
|
|
62
|
+
from .server import ApplicationServer, run_app
|
|
63
|
+
|
|
64
|
+
__all__ = [
|
|
65
|
+
# 配置
|
|
66
|
+
"BaseConfig",
|
|
67
|
+
"CORSSettings",
|
|
68
|
+
"CacheSettings",
|
|
69
|
+
"LogSettings",
|
|
70
|
+
"ServerSettings",
|
|
71
|
+
# 常量
|
|
72
|
+
"ComponentName",
|
|
73
|
+
"MiddlewareName",
|
|
74
|
+
"SchedulerMode",
|
|
75
|
+
"ServiceType",
|
|
76
|
+
# 应用框架
|
|
77
|
+
"FoundationApp",
|
|
78
|
+
# 基类
|
|
79
|
+
"Component",
|
|
80
|
+
"Middleware",
|
|
81
|
+
# 中间件
|
|
82
|
+
"CORSMiddleware",
|
|
83
|
+
"RequestLoggingMiddleware",
|
|
84
|
+
# 组件
|
|
85
|
+
"CacheComponent",
|
|
86
|
+
"DatabaseComponent",
|
|
87
|
+
"MigrationComponent",
|
|
88
|
+
"SchedulerComponent",
|
|
89
|
+
"TaskComponent",
|
|
90
|
+
# 依赖注入容器
|
|
91
|
+
"Container",
|
|
92
|
+
"Lifetime",
|
|
93
|
+
"Scope",
|
|
94
|
+
"ServiceDescriptor",
|
|
95
|
+
# 事件系统
|
|
96
|
+
"Event",
|
|
97
|
+
"EventBus",
|
|
98
|
+
"EventConsumer",
|
|
99
|
+
"EventLoggingMiddleware",
|
|
100
|
+
"EventMiddleware",
|
|
101
|
+
# 迁移
|
|
102
|
+
"MigrationManager",
|
|
103
|
+
# HTTP 中间件装饰器
|
|
104
|
+
"log_request",
|
|
105
|
+
# 事务管理
|
|
106
|
+
"TransactionManager",
|
|
107
|
+
"TransactionRequiredError",
|
|
108
|
+
"ensure_transaction",
|
|
109
|
+
"transactional",
|
|
110
|
+
"transactional_context",
|
|
111
|
+
# RPC通信
|
|
112
|
+
"rpc",
|
|
113
|
+
# 调度器启动器
|
|
114
|
+
"run_scheduler",
|
|
115
|
+
"run_scheduler_sync",
|
|
116
|
+
# 服务器集成
|
|
117
|
+
"ApplicationServer",
|
|
118
|
+
"run_app",
|
|
119
|
+
]
|
|
120
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""应用框架模块。
|
|
2
|
+
|
|
3
|
+
提供 FoundationApp、Middleware 和 Component 系统。
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .base import Component, FoundationApp, Middleware
|
|
7
|
+
from .components import (
|
|
8
|
+
AdminConsoleComponent,
|
|
9
|
+
CacheComponent,
|
|
10
|
+
DatabaseComponent,
|
|
11
|
+
MigrationComponent,
|
|
12
|
+
SchedulerComponent,
|
|
13
|
+
TaskComponent,
|
|
14
|
+
)
|
|
15
|
+
from .middlewares import (
|
|
16
|
+
CORSMiddleware,
|
|
17
|
+
RequestLoggingMiddleware,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
# 应用框架
|
|
22
|
+
"FoundationApp",
|
|
23
|
+
# 基类
|
|
24
|
+
"Component",
|
|
25
|
+
"Middleware",
|
|
26
|
+
# 中间件
|
|
27
|
+
"CORSMiddleware",
|
|
28
|
+
"RequestLoggingMiddleware",
|
|
29
|
+
# 组件
|
|
30
|
+
"AdminConsoleComponent",
|
|
31
|
+
"CacheComponent",
|
|
32
|
+
"DatabaseComponent",
|
|
33
|
+
"MigrationComponent",
|
|
34
|
+
"SchedulerComponent",
|
|
35
|
+
"TaskComponent",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|