@clonegod/ttd-core 3.1.41 → 3.1.43
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.
- package/dist/analyze/index.js +21 -17
- package/dist/appconfig/EnvArgs.d.ts +0 -4
- package/dist/appconfig/env_registry.js +1 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
package/dist/analyze/index.js
CHANGED
|
@@ -53,25 +53,26 @@ const index_1 = require("../index");
|
|
|
53
53
|
const service_ports_1 = require("../constants/service_ports");
|
|
54
54
|
const ws_client_1 = require("./ws_client");
|
|
55
55
|
Object.defineProperty(exports, "AnalyzeWsClient", { enumerable: true, get: function () { return ws_client_1.AnalyzeWsClient; } });
|
|
56
|
-
const
|
|
56
|
+
const httpHeaders = { 'Content-Type': 'application/json' };
|
|
57
|
+
const httpAgent = new http.Agent({ keepAlive: true, maxSockets: 10 });
|
|
58
|
+
function getAnalyzeHost() {
|
|
59
|
+
var _a;
|
|
57
60
|
try {
|
|
58
|
-
return (0, core_env_1.getCoreEnv)();
|
|
61
|
+
return ((_a = (0, core_env_1.getCoreEnv)()) === null || _a === void 0 ? void 0 : _a.trade_analyze_host) || '';
|
|
59
62
|
}
|
|
60
|
-
catch (
|
|
61
|
-
return
|
|
63
|
+
catch (_b) {
|
|
64
|
+
return '';
|
|
62
65
|
}
|
|
63
|
-
}
|
|
64
|
-
const ANALYZE_HOST = (_env === null || _env === void 0 ? void 0 : _env.trade_analyze_host) || '';
|
|
65
|
-
const ANALYZE_HTTP_BASE = ANALYZE_HOST ? `http://${ANALYZE_HOST}:${service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP}/trade/analyze` : '';
|
|
66
|
-
const ANALYZE_WS_URL = ANALYZE_HOST ? `ws://${ANALYZE_HOST}:${service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP}/trade/analyze/ws/ingest` : '';
|
|
67
|
-
const httpHeaders = { 'Content-Type': 'application/json' };
|
|
68
|
-
const httpAgent = new http.Agent({ keepAlive: true, maxSockets: 10 });
|
|
66
|
+
}
|
|
69
67
|
let _wsClient = null;
|
|
70
68
|
function getWsClient() {
|
|
71
|
-
|
|
69
|
+
const host = getAnalyzeHost();
|
|
70
|
+
if (!host)
|
|
72
71
|
return null;
|
|
73
|
-
if (!_wsClient)
|
|
74
|
-
|
|
72
|
+
if (!_wsClient) {
|
|
73
|
+
const url = `ws://${host}:${service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP}/trade/analyze/ws/ingest`;
|
|
74
|
+
_wsClient = new ws_client_1.AnalyzeWsClient(url);
|
|
75
|
+
}
|
|
75
76
|
return _wsClient;
|
|
76
77
|
}
|
|
77
78
|
const WS_TYPES = new Set([
|
|
@@ -85,7 +86,8 @@ const HTTP_PATH = {
|
|
|
85
86
|
TradeResultType: '/ingest/trade-result',
|
|
86
87
|
};
|
|
87
88
|
const report_data_to_analyze = (type, data) => {
|
|
88
|
-
|
|
89
|
+
const host = getAnalyzeHost();
|
|
90
|
+
if (!host)
|
|
89
91
|
return;
|
|
90
92
|
if (WS_TYPES.has(type)) {
|
|
91
93
|
const client = getWsClient();
|
|
@@ -99,7 +101,8 @@ const report_data_to_analyze = (type, data) => {
|
|
|
99
101
|
return;
|
|
100
102
|
}
|
|
101
103
|
try {
|
|
102
|
-
|
|
104
|
+
const url = `http://${host}:${service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP}/trade/analyze${path}`;
|
|
105
|
+
axios_1.default.post(url, data, { headers: httpHeaders, timeout: 3000, httpAgent })
|
|
103
106
|
.then(() => (0, index_1.log_trace)(`[analyze] report ${type} ok`))
|
|
104
107
|
.catch(err => (0, index_1.log_warn)(`[analyze] report ${type} fail: ${err.message}`));
|
|
105
108
|
}
|
|
@@ -109,10 +112,11 @@ const report_data_to_analyze = (type, data) => {
|
|
|
109
112
|
};
|
|
110
113
|
exports.report_data_to_analyze = report_data_to_analyze;
|
|
111
114
|
const get_pool_latest_quote_price = (unique_orderbook_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
-
|
|
115
|
+
const host = getAnalyzeHost();
|
|
116
|
+
if (!host || (0, index_1.isEmpty)(unique_orderbook_id))
|
|
113
117
|
return null;
|
|
114
118
|
try {
|
|
115
|
-
const url =
|
|
119
|
+
const url = `http://${host}:${service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP}/trade/analyze/quote/price-msg?unique_orderbook_id=${unique_orderbook_id}`;
|
|
116
120
|
const res = (yield axios_1.default.get(url, { headers: httpHeaders, timeout: 3000, httpAgent })).data;
|
|
117
121
|
return res.data;
|
|
118
122
|
}
|
|
@@ -35,10 +35,6 @@ export declare class EnvArgs {
|
|
|
35
35
|
encryption_key: string;
|
|
36
36
|
providers_file_path: string;
|
|
37
37
|
fixed_symbol_address_file: string;
|
|
38
|
-
alert_analyze_host: string;
|
|
39
|
-
alert_flush_size: number;
|
|
40
|
-
alert_flush_ms: number;
|
|
41
|
-
alert_dedup_window_ms: number;
|
|
42
38
|
namespace: string;
|
|
43
39
|
server_ip_list: string;
|
|
44
40
|
ip_exclude_prefix: string;
|
|
@@ -47,9 +47,5 @@ registerEnvVars({
|
|
|
47
47
|
fixed_symbol_address_file: { env: 'FIXED_SYMBOL_ADDRESS_FILE', type: 'string', default: '', desc: '固定 symbol/address 映射文件路径(覆盖默认按 CHAIN_ID 推断的路径)' },
|
|
48
48
|
server_ip_list: { env: 'SERVER_IP_LIST', type: 'string', default: '', desc: '服务器可用 IP 列表(逗号分隔);配置后优先使用;为空则从网卡探测并结合 IP_EXCLUDE_PREFIX 过滤' },
|
|
49
49
|
ip_exclude_prefix: { env: 'IP_EXCLUDE_PREFIX', type: 'string', default: '192.168', desc: 'IP 前缀排除列表(逗号分隔)' },
|
|
50
|
-
|
|
51
|
-
alert_flush_size: { env: 'ALERT_FLUSH_SIZE', type: 'number', default: 10, desc: 'alert 批处理阈值(条数)' },
|
|
52
|
-
alert_flush_ms: { env: 'ALERT_FLUSH_MS', type: 'number', default: 5000, desc: 'alert 批处理阈值(ms)' },
|
|
53
|
-
alert_dedup_window_ms: { env: 'ALERT_DEDUP_WINDOW_MS', type: 'number', default: 60000, desc: 'alert 去重窗口(ms)' },
|
|
54
|
-
namespace: { env: 'NAMESPACE', type: 'string', default: '', desc: '服务命名空间(用于日志/告警 source 前缀等)' },
|
|
50
|
+
namespace: { env: 'NAMESPACE', type: 'string', default: '', desc: '服务命名空间(用于日志 source 前缀等)' },
|
|
55
51
|
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -97,7 +97,6 @@ __exportStar(require("./quote"), exports);
|
|
|
97
97
|
__exportStar(require("./token"), exports);
|
|
98
98
|
__exportStar(require("./trade"), exports);
|
|
99
99
|
__exportStar(require("./chains"), exports);
|
|
100
|
-
__exportStar(require("./alert"), exports);
|
|
101
100
|
__exportStar(require("./log_bus"), exports);
|
|
102
101
|
__exportStar(require("./ws"), exports);
|
|
103
102
|
__exportStar(require("./util"), exports);
|