init
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 神之一手(one_divine_lot)DSH 插件入口
|
||||
*
|
||||
* 迭代 01:分仓管理工具
|
||||
* - S2 数据源直连 QMT Bridge REST(技术约束-003)
|
||||
* - S3 设置管理(策略=标签 + 显示开关)
|
||||
* - S4 分仓数据本地存储
|
||||
* - S5 分仓逻辑(份额分配/查询)
|
||||
* - S6 服务端 HTTP API(webServer /odl/api/*)
|
||||
* - S7 客户端 tab 展示(客户端插件)
|
||||
*
|
||||
* 依据:docs/02-计划/计划-分仓管理工具.md、docs/04-迭代记录/01-分仓管理工具/
|
||||
* 设计约束:技术约束-001/003、产品约束-001/002/003
|
||||
*/
|
||||
|
||||
import { QmtBridgeRestDataSource } from './data-source/qmt-bridge-rest.js';
|
||||
import { registerSettings } from './settings.js';
|
||||
import { AllocationStorage } from './storage.js';
|
||||
import { PositionManager } from './position/manager.js';
|
||||
import { registerApi } from './api.js';
|
||||
|
||||
const name = 'one-divine-lot';
|
||||
|
||||
// 依赖服务:settings(S3)、webServer(S6 api)
|
||||
const inject = ['settings', 'webServer'];
|
||||
|
||||
async function apply(ctx, config) {
|
||||
const logger = ctx.logger;
|
||||
|
||||
// S2: 数据源(REST 直连 QMT Bridge)
|
||||
const dataSource = new QmtBridgeRestDataSource({
|
||||
baseUrl: config?.qmtBaseUrl,
|
||||
timeoutMs: config?.qmtTimeoutMs,
|
||||
});
|
||||
|
||||
// S3: 设置管理(策略=标签 + 显示开关)
|
||||
const settings = registerSettings(ctx, config);
|
||||
|
||||
// S4: 分仓数据本地存储
|
||||
const storage = new AllocationStorage({
|
||||
dataDir: config?.dataDir,
|
||||
});
|
||||
|
||||
// S5: 分仓逻辑(份额分配/查询)
|
||||
const manager = new PositionManager({ dataSource, storage });
|
||||
|
||||
// S6: 服务端 HTTP API
|
||||
registerApi(ctx, { manager, settings });
|
||||
|
||||
// 启动时可用性检查(日志,不阻塞)
|
||||
dataSource.isAvailable().then((ok) => {
|
||||
logger.info(`[one-divine-lot] QMT Bridge REST 可用: ${ok}`);
|
||||
}).catch((e) => {
|
||||
logger.warn(`[one-divine-lot] QMT Bridge REST 检查失败: ${e.message}`);
|
||||
});
|
||||
|
||||
ctx.effect(() => {
|
||||
logger.info('[one-divine-lot] 插件已加载(S1-S6 就绪)');
|
||||
return () => {
|
||||
logger.info('[one-divine-lot] 插件已释放');
|
||||
};
|
||||
}, 'one-divine-lot.dispose');
|
||||
}
|
||||
|
||||
export { name, inject, apply };
|
||||
Reference in New Issue
Block a user