|
|
||
|---|---|---|
| .. | ||
| integration | ||
| payment | ||
| system | ||
| task | ||
| README.md | ||
| config_store.go | ||
| data.go | ||
| data_scope.go | ||
| data_scope_audit.go | ||
| data_scope_audit_test.go | ||
| data_scope_record.go | ||
| data_scope_test.go | ||
| database.go | ||
| gorm_logger_test.go | ||
| initialization_backend.go | ||
| initialization_backend_test.go | ||
| integration_config.go | ||
| integration_config_test.go | ||
| migrations_test.go | ||
| mongo.go | ||
| runtime_clients.go | ||
| runtime_clients_test.go | ||
README.md
Data Layer
data owns database clients, persistence models, migrations, explicit runtime
configuration reloads, and repository implementations. File watching and
immutable configuration snapshots belong to internal/config.
system/: system repositories and system table persistencetask/: timed-task tables and task persistenceintegration/:sys_integration_configsand integration configuration persistencepayment/: payment-order persistence- each subpackage owns its Wire
ProviderSet; the root package only binds the sharedDatainfrastructure and aggregates those sets, mirroringbiz - root files: shared database lifecycle, runtime clients, configuration orchestration, data-scope auditing, and migration orchestration
新增数据模块时创建 internal/data/<module>,提供 ProviderSet 和
Migrations(),再在 internal/modules/<module>/definition.go 注册迁移与
管理面,最后在根 data.ProviderSet 中注册该模块。根 data 不应直接
拥有业务表 PO,也不应让一个模块引用另一个模块的私有 PO。
Root files intentionally stay in one package because they share Data state and
reload locks. Do not split them into packages only to reduce file count.
当前内置数据模块为 system、integration、task 和 payment。其中:
system只拥有sys_*系统表、系统仓储、种子和系统维护清理;integration唯一拥有sys_integration_configs表模型、配置仓储和通信默认值;task只拥有定时任务与任务日志表;payment只拥有pay_orders等支付持久化,通过biz/integration.PaymentConfigReader读取支付配置,不感知 integration 的 PO 或表结构。
配置文件持久化、数据库切换、Redis/Mongo/对象存储重载仍属于根 data 的生命周期编排, 不等同于某个业务模块的表仓储。