@clonegod/ttd-core 3.1.18 → 3.1.19
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/alert/reporter.js +12 -6
- package/dist/analyze/index.d.ts +5 -3
- package/dist/analyze/index.js +81 -19
- package/dist/analyze/ws_client.d.ts +15 -0
- package/dist/analyze/ws_client.js +88 -0
- package/dist/app_config/AppConfig.js +2 -4
- package/dist/app_config/EnvArgs.d.ts +22 -0
- package/dist/app_config/EnvArgs.js +45 -38
- package/dist/app_config/core_env.d.ts +3 -0
- package/dist/app_config/core_env.js +14 -0
- package/dist/app_config/env_loader.d.ts +3 -3
- package/dist/app_config/env_loader.js +8 -17
- package/dist/app_config/env_registry.js +25 -20
- package/dist/app_config/index.d.ts +1 -0
- package/dist/app_config/index.js +1 -0
- package/dist/cache/arb_cache.d.ts +1 -4
- package/dist/cache/arb_cache.js +10 -70
- package/dist/cache/arb_event_sub.js +2 -1
- package/dist/constants/service_ports.d.ts +0 -1
- package/dist/constants/service_ports.js +0 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +17 -28
- package/dist/market_price/estimate_token_amount.js +14 -14
- package/dist/pool/cache_pool_config.js +4 -2
- package/dist/quote/on_quote_response.d.ts +0 -1
- package/dist/quote/on_quote_response.js +3 -16
- package/dist/quote/to_price_message.js +2 -1
- package/dist/redis/redis_client.d.ts +1 -0
- package/dist/redis/redis_client.js +8 -3
- package/dist/redis/redis_connection.js +4 -2
- package/dist/token/cache_token_config.js +3 -1
- package/dist/token/fixed_symbol_address.js +4 -3
- package/dist/token/price/get_bsc_token_price.js +1 -1
- package/dist/token/price/get_eth_token_price.d.ts +1 -1
- package/dist/token/price/get_eth_token_price.js +1 -1
- package/dist/token/price/get_solana_token_price.js +3 -3
- package/dist/token/zh_pinyin_map.js +4 -3
- package/dist/trade/abstract_tx_check.js +1 -1
- package/dist/trade/handle_order_message.js +1 -1
- package/dist/util/crypto.js +2 -2
- package/dist/util/ip_util.js +9 -3
- package/dist/ws/ws_client.js +14 -14
- package/package.json +1 -1
- package/types/index.d.ts +0 -40
- package/dist/cache/redis_client.d.ts +0 -3
- package/dist/cache/redis_client.js +0 -45
- package/dist/cache/redis_cmd.d.ts +0 -328
- package/dist/cache/redis_cmd.js +0 -285
- package/dist/chains/evm_gas_options.d.ts +0 -9
- package/dist/chains/evm_gas_options.js +0 -2
- package/dist/util/config_center_http.d.ts +0 -1
- package/dist/util/config_center_http.js +0 -14
- package/dist/ws/ws_client_example.d.ts +0 -5
- package/dist/ws/ws_client_example.js +0 -69
package/dist/alert/reporter.js
CHANGED
|
@@ -12,7 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.reportAlert = reportAlert;
|
|
13
13
|
exports.flushAlerts = flushAlerts;
|
|
14
14
|
const types_1 = require("./types");
|
|
15
|
+
const core_env_1 = require("../app_config/core_env");
|
|
15
16
|
const codes_1 = require("./codes");
|
|
17
|
+
const service_ports_1 = require("../constants/service_ports");
|
|
16
18
|
let _axios = null;
|
|
17
19
|
function getAxios() {
|
|
18
20
|
if (!_axios)
|
|
@@ -20,13 +22,17 @@ function getAxios() {
|
|
|
20
22
|
return _axios;
|
|
21
23
|
}
|
|
22
24
|
function getConfig() {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
const coreEnv = (0, core_env_1.getCoreEnv)();
|
|
27
|
+
const appName = (_a = coreEnv === null || coreEnv === void 0 ? void 0 : coreEnv.app_name) !== null && _a !== void 0 ? _a : '';
|
|
28
|
+
const ns = (_b = coreEnv.namespace) !== null && _b !== void 0 ? _b : '';
|
|
23
29
|
return {
|
|
24
|
-
analyze_host:
|
|
25
|
-
analyze_port:
|
|
26
|
-
flush_size:
|
|
27
|
-
flush_ms:
|
|
28
|
-
dedup_window_ms:
|
|
29
|
-
source_prefix:
|
|
30
|
+
analyze_host: (_c = coreEnv.alert_analyze_host) !== null && _c !== void 0 ? _c : '',
|
|
31
|
+
analyze_port: service_ports_1.SERVICE_PORT.TRADE_ANALYZE_HTTP,
|
|
32
|
+
flush_size: Number((_d = coreEnv.alert_flush_size) !== null && _d !== void 0 ? _d : 10),
|
|
33
|
+
flush_ms: Number((_e = coreEnv.alert_flush_ms) !== null && _e !== void 0 ? _e : 5000),
|
|
34
|
+
dedup_window_ms: Number((_f = coreEnv.alert_dedup_window_ms) !== null && _f !== void 0 ? _f : 60000),
|
|
35
|
+
source_prefix: appName || ns || 'unknown',
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
const buffer = new Map();
|
package/dist/analyze/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
1
|
+
import { PriceMessageType } from "../../types";
|
|
2
|
+
import { AnalyzeWsClient } from "./ws_client";
|
|
3
|
+
export declare const report_data_to_analyze: (type: string, data: any) => void;
|
|
4
|
+
export declare const get_pool_latest_quote_price: (unique_orderbook_id: string) => Promise<PriceMessageType | null>;
|
|
5
|
+
export { AnalyzeWsClient };
|
package/dist/analyze/index.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,32 +45,61 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
46
|
};
|
|
14
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.get_pool_latest_quote_price = exports.
|
|
48
|
+
exports.AnalyzeWsClient = exports.get_pool_latest_quote_price = exports.report_data_to_analyze = void 0;
|
|
16
49
|
const axios_1 = __importDefault(require("axios"));
|
|
50
|
+
const http = __importStar(require("http"));
|
|
51
|
+
const core_env_1 = require("../app_config/core_env");
|
|
17
52
|
const index_1 = require("../index");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
53
|
+
const service_ports_1 = require("../constants/service_ports");
|
|
54
|
+
const ws_client_1 = require("./ws_client");
|
|
55
|
+
Object.defineProperty(exports, "AnalyzeWsClient", { enumerable: true, get: function () { return ws_client_1.AnalyzeWsClient; } });
|
|
56
|
+
const _env = (() => {
|
|
57
|
+
try {
|
|
58
|
+
return (0, core_env_1.getCoreEnv)();
|
|
59
|
+
}
|
|
60
|
+
catch (_a) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
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 });
|
|
69
|
+
let _wsClient = null;
|
|
70
|
+
function getWsClient() {
|
|
71
|
+
if (!ANALYZE_WS_URL)
|
|
72
|
+
return null;
|
|
73
|
+
if (!_wsClient)
|
|
74
|
+
_wsClient = new ws_client_1.AnalyzeWsClient(ANALYZE_WS_URL);
|
|
75
|
+
return _wsClient;
|
|
76
|
+
}
|
|
77
|
+
const WS_TYPES = new Set([
|
|
78
|
+
'PreTradeEvent',
|
|
79
|
+
'PriceMessageType',
|
|
80
|
+
'DepthLevels',
|
|
81
|
+
'QuoteVerify',
|
|
82
|
+
]);
|
|
83
|
+
const HTTP_PATH = {
|
|
24
84
|
OrderMessageType: '/ingest/order',
|
|
25
|
-
DepthLevels: '/ingest/depth',
|
|
26
|
-
TickLiquidity: '/ingest/tick',
|
|
27
85
|
TradeResultType: '/ingest/trade-result',
|
|
28
|
-
SendTxLogType: '/ingest/send-tx',
|
|
29
|
-
QuoteVerify: '/ingest/quote-verify',
|
|
30
86
|
};
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
87
|
+
const report_data_to_analyze = (type, data) => {
|
|
88
|
+
if (!ANALYZE_HOST)
|
|
33
89
|
return;
|
|
34
|
-
|
|
90
|
+
if (WS_TYPES.has(type)) {
|
|
91
|
+
const client = getWsClient();
|
|
92
|
+
if (client)
|
|
93
|
+
client.send(type, data);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const path = HTTP_PATH[type];
|
|
35
97
|
if (!path) {
|
|
36
98
|
(0, index_1.log_warn)(`[analyze] unknown report type: ${type}`);
|
|
37
99
|
return;
|
|
38
100
|
}
|
|
39
101
|
try {
|
|
40
|
-
axios_1.default.post(
|
|
102
|
+
axios_1.default.post(ANALYZE_HTTP_BASE + path, data, { headers: httpHeaders, timeout: 3000, httpAgent })
|
|
41
103
|
.then(() => (0, index_1.log_trace)(`[analyze] report ${type} ok`))
|
|
42
104
|
.catch(err => (0, index_1.log_warn)(`[analyze] report ${type} fail: ${err.message}`));
|
|
43
105
|
}
|
|
@@ -45,13 +107,13 @@ const report_trade_analyze_data = (type, message) => {
|
|
|
45
107
|
(0, index_1.log_warn)(`[analyze] report ${type} error: ${err.message}`);
|
|
46
108
|
}
|
|
47
109
|
};
|
|
48
|
-
exports.
|
|
110
|
+
exports.report_data_to_analyze = report_data_to_analyze;
|
|
49
111
|
const get_pool_latest_quote_price = (unique_orderbook_id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
if (!
|
|
112
|
+
if (!ANALYZE_HTTP_BASE || (0, index_1.isEmpty)(unique_orderbook_id))
|
|
51
113
|
return null;
|
|
52
114
|
try {
|
|
53
|
-
const url = `${
|
|
54
|
-
const res = (yield axios_1.default.get(url, { headers, timeout: 3000 })).data;
|
|
115
|
+
const url = `${ANALYZE_HTTP_BASE}/quote/price-msg?unique_orderbook_id=${unique_orderbook_id}`;
|
|
116
|
+
const res = (yield axios_1.default.get(url, { headers: httpHeaders, timeout: 3000, httpAgent })).data;
|
|
55
117
|
return res.data;
|
|
56
118
|
}
|
|
57
119
|
catch (err) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class AnalyzeWsClient {
|
|
2
|
+
private readonly url;
|
|
3
|
+
private ws;
|
|
4
|
+
private reconnectTimer;
|
|
5
|
+
private connected;
|
|
6
|
+
private queue;
|
|
7
|
+
private readonly MAX_QUEUE;
|
|
8
|
+
private droppedCount;
|
|
9
|
+
private lastDroppedLogAt;
|
|
10
|
+
constructor(url: string);
|
|
11
|
+
private connect;
|
|
12
|
+
private scheduleReconnect;
|
|
13
|
+
private flushQueue;
|
|
14
|
+
send(type: string, data: any): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AnalyzeWsClient = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
const index_1 = require("../index");
|
|
9
|
+
class AnalyzeWsClient {
|
|
10
|
+
constructor(url) {
|
|
11
|
+
this.url = url;
|
|
12
|
+
this.ws = null;
|
|
13
|
+
this.reconnectTimer = null;
|
|
14
|
+
this.connected = false;
|
|
15
|
+
this.queue = [];
|
|
16
|
+
this.MAX_QUEUE = 100000;
|
|
17
|
+
this.droppedCount = 0;
|
|
18
|
+
this.lastDroppedLogAt = 0;
|
|
19
|
+
this.connect();
|
|
20
|
+
}
|
|
21
|
+
connect() {
|
|
22
|
+
try {
|
|
23
|
+
this.ws = new ws_1.default(this.url);
|
|
24
|
+
this.ws.on('open', () => {
|
|
25
|
+
this.connected = true;
|
|
26
|
+
(0, index_1.log_info)(`[AnalyzeWs] connected: ${this.url}`);
|
|
27
|
+
this.flushQueue();
|
|
28
|
+
});
|
|
29
|
+
this.ws.on('close', () => {
|
|
30
|
+
this.connected = false;
|
|
31
|
+
this.ws = null;
|
|
32
|
+
this.scheduleReconnect();
|
|
33
|
+
});
|
|
34
|
+
this.ws.on('error', (err) => {
|
|
35
|
+
(0, index_1.log_debug)(`[AnalyzeWs] error: ${(err === null || err === void 0 ? void 0 : err.message) || err}`);
|
|
36
|
+
this.connected = false;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
(0, index_1.log_debug)(`[AnalyzeWs] connect exception: ${err.message}`);
|
|
41
|
+
this.scheduleReconnect();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
scheduleReconnect() {
|
|
45
|
+
if (this.reconnectTimer)
|
|
46
|
+
return;
|
|
47
|
+
this.reconnectTimer = setTimeout(() => {
|
|
48
|
+
this.reconnectTimer = null;
|
|
49
|
+
this.connect();
|
|
50
|
+
}, 3000);
|
|
51
|
+
}
|
|
52
|
+
flushQueue() {
|
|
53
|
+
var _a;
|
|
54
|
+
while (this.queue.length > 0 && this.connected && ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN) {
|
|
55
|
+
const msg = this.queue.shift();
|
|
56
|
+
try {
|
|
57
|
+
this.ws.send(msg);
|
|
58
|
+
}
|
|
59
|
+
catch (_b) {
|
|
60
|
+
this.queue.unshift(msg);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
send(type, data) {
|
|
66
|
+
var _a;
|
|
67
|
+
const msg = JSON.stringify({ type, data });
|
|
68
|
+
if (this.connected && ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN) {
|
|
69
|
+
try {
|
|
70
|
+
this.ws.send(msg);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
catch (_b) {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (this.queue.length >= this.MAX_QUEUE) {
|
|
77
|
+
this.queue.shift();
|
|
78
|
+
this.droppedCount++;
|
|
79
|
+
const now = Date.now();
|
|
80
|
+
if (now - this.lastDroppedLogAt > 10000) {
|
|
81
|
+
this.lastDroppedLogAt = now;
|
|
82
|
+
(0, index_1.log_warn)(`[AnalyzeWs] queue full, dropped ${this.droppedCount} msgs total`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
this.queue.push(msg);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.AnalyzeWsClient = AnalyzeWsClient;
|
|
@@ -16,10 +16,12 @@ exports.AppConfig = void 0;
|
|
|
16
16
|
const events_1 = __importDefault(require("events"));
|
|
17
17
|
const __1 = require("..");
|
|
18
18
|
const EnvArgs_1 = require("./EnvArgs");
|
|
19
|
+
const core_env_1 = require("./core_env");
|
|
19
20
|
class AppConfig extends events_1.default {
|
|
20
21
|
constructor() {
|
|
21
22
|
super();
|
|
22
23
|
this.env_args = new EnvArgs_1.EnvArgs();
|
|
24
|
+
(0, core_env_1.setCoreEnv)(this.env_args);
|
|
23
25
|
let { chain_id, app_name, dex_id } = this.env_args;
|
|
24
26
|
this.app_full_name = `${chain_id}_${dex_id}_${app_name}`;
|
|
25
27
|
global.app_config = this;
|
|
@@ -28,10 +30,6 @@ class AppConfig extends events_1.default {
|
|
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
31
|
this.arb_cache = (0, __1.getArbCache)(this.env_args);
|
|
30
32
|
yield this.arb_cache.init();
|
|
31
|
-
let common_service_config = yield this.arb_cache.get_common_service();
|
|
32
|
-
if ((0, __1.isEmpty)(common_service_config)) {
|
|
33
|
-
throw new Error(`get_common_service from cache failed! read from cache=${(0, __1.to_json_str)(common_service_config)}`);
|
|
34
|
-
}
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
subscribe_config_change() {
|
|
@@ -4,10 +4,15 @@ export declare class EnvArgs {
|
|
|
4
4
|
app_base_dir: string;
|
|
5
5
|
chain_id: CHAIN_ID;
|
|
6
6
|
dex_id: DEX_ID;
|
|
7
|
+
log_level: string;
|
|
8
|
+
log_depth: number;
|
|
9
|
+
server_id: string;
|
|
7
10
|
redis_host: string;
|
|
8
11
|
redis_port: string;
|
|
9
12
|
config_center_host: string;
|
|
13
|
+
enable_init_cache: string;
|
|
10
14
|
trade_analyze_url: string;
|
|
15
|
+
trade_analyze_host: string;
|
|
11
16
|
rpc_endpoint: string;
|
|
12
17
|
ws_endpoint: string;
|
|
13
18
|
grpc_endpoint: string;
|
|
@@ -19,11 +24,28 @@ export declare class EnvArgs {
|
|
|
19
24
|
quote_pool_address: string;
|
|
20
25
|
quote_pool_name: string;
|
|
21
26
|
quote_pool_fee_rate: number;
|
|
27
|
+
tick_cache_force_full_refresh_interval: number;
|
|
28
|
+
depth_cex_bps: number;
|
|
29
|
+
group_id: string;
|
|
22
30
|
trade_group_id: string;
|
|
23
31
|
trade_pair: string;
|
|
32
|
+
trade_log_report_cex_url: string;
|
|
33
|
+
trade_log_report_cex_data_type: string;
|
|
24
34
|
token_price_cache_seconds: number;
|
|
35
|
+
token_market_price_url: string;
|
|
25
36
|
wallet_dir: string;
|
|
37
|
+
encryption_key: string;
|
|
26
38
|
providers_file_path: string;
|
|
39
|
+
fixed_symbol_address_file: string;
|
|
40
|
+
zh_pinyin_map_file: string;
|
|
41
|
+
alert_analyze_host: string;
|
|
42
|
+
alert_flush_size: number;
|
|
43
|
+
alert_flush_ms: number;
|
|
44
|
+
alert_dedup_window_ms: number;
|
|
45
|
+
namespace: string;
|
|
46
|
+
server_ip_list: string;
|
|
47
|
+
ip_exclude_prefix: string;
|
|
48
|
+
protected _cfg: Record<string, any>;
|
|
27
49
|
constructor(chain_id?: CHAIN_ID, dex_id?: DEX_ID);
|
|
28
50
|
print(moduleName?: string): void;
|
|
29
51
|
}
|
|
@@ -3,26 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EnvArgs = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const env_loader_1 = require("./env_loader");
|
|
6
|
-
const ENVARGS_KEYS = [
|
|
7
|
-
'app_name', 'app_base_dir', 'chain_id', 'dex_id',
|
|
8
|
-
'redis_host', 'redis_port',
|
|
9
|
-
'config_center_host', 'trade_analyze_url',
|
|
10
|
-
'rpc_endpoint', 'ws_endpoint', 'grpc_endpoint', 'grpc_token',
|
|
11
|
-
'auto_quote_enable', 'auto_quote_interval_mills',
|
|
12
|
-
'quote_pair', 'quote_amount_usd', 'quote_pool_address', 'quote_pool_name', 'quote_pool_fee_rate',
|
|
13
|
-
'trade_group_id', 'trade_pair',
|
|
14
|
-
'token_price_cache_seconds', 'wallet_dir',
|
|
15
|
-
'providers_file_path',
|
|
16
|
-
];
|
|
17
6
|
class EnvArgs {
|
|
18
7
|
constructor(chain_id, dex_id) {
|
|
19
|
-
var _a;
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
20
9
|
const overrides = {};
|
|
21
10
|
if (chain_id)
|
|
22
11
|
overrides.chain_id = chain_id;
|
|
23
12
|
if (dex_id)
|
|
24
13
|
overrides.dex_id = dex_id;
|
|
25
|
-
const cfg = (0, env_loader_1.loadEnvConfig)(
|
|
14
|
+
const cfg = (0, env_loader_1.loadEnvConfig)(overrides);
|
|
15
|
+
this._cfg = cfg;
|
|
26
16
|
this.app_name = cfg.app_name || '';
|
|
27
17
|
this.app_base_dir = cfg.app_base_dir || '';
|
|
28
18
|
this.chain_id = (cfg.chain_id || '').toUpperCase();
|
|
@@ -30,33 +20,50 @@ class EnvArgs {
|
|
|
30
20
|
if ((0, __1.isEmpty)(this.chain_id)) {
|
|
31
21
|
throw new Error(`environment: CHAIN_ID is empty!!!`);
|
|
32
22
|
}
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
23
|
+
this.log_level = (_a = cfg.log_level) !== null && _a !== void 0 ? _a : '';
|
|
24
|
+
this.log_depth = cfg.log_depth;
|
|
25
|
+
this.server_id = (_b = cfg.server_id) !== null && _b !== void 0 ? _b : '';
|
|
26
|
+
this.redis_host = cfg.redis_host;
|
|
27
|
+
this.redis_port = String(cfg.redis_port);
|
|
28
|
+
this.config_center_host = cfg.config_center_host;
|
|
29
|
+
this.enable_init_cache = (_c = cfg.enable_init_cache) !== null && _c !== void 0 ? _c : '';
|
|
30
|
+
this.trade_analyze_url = cfg.trade_analyze_url;
|
|
31
|
+
this.trade_analyze_host = (_d = cfg.trade_analyze_host) !== null && _d !== void 0 ? _d : '';
|
|
32
|
+
this.rpc_endpoint = cfg.rpc_endpoint;
|
|
33
|
+
this.ws_endpoint = cfg.ws_endpoint;
|
|
34
|
+
this.grpc_endpoint = cfg.grpc_endpoint;
|
|
35
|
+
this.grpc_token = cfg.grpc_token;
|
|
36
|
+
this.auto_quote_enable = cfg.auto_quote_enable;
|
|
37
|
+
this.auto_quote_interval_mills = cfg.auto_quote_interval_mills;
|
|
38
|
+
this.quote_pair = cfg.quote_pair;
|
|
39
|
+
this.quote_amount_usd = cfg.quote_amount_usd;
|
|
40
|
+
this.quote_pool_address = cfg.quote_pool_address;
|
|
41
|
+
this.quote_pool_name = cfg.quote_pool_name;
|
|
42
|
+
this.quote_pool_fee_rate = cfg.quote_pool_fee_rate;
|
|
43
|
+
this.tick_cache_force_full_refresh_interval = cfg.tick_cache_force_full_refresh_interval;
|
|
44
|
+
this.depth_cex_bps = cfg.depth_cex_bps;
|
|
45
|
+
this.group_id = (_e = cfg.group_id) !== null && _e !== void 0 ? _e : '';
|
|
46
|
+
this.trade_group_id = cfg.trade_group_id;
|
|
47
|
+
this.trade_pair = cfg.trade_pair;
|
|
48
|
+
this.trade_log_report_cex_url = (_f = cfg.trade_log_report_cex_url) !== null && _f !== void 0 ? _f : '';
|
|
49
|
+
this.trade_log_report_cex_data_type = (_g = cfg.trade_log_report_cex_data_type) !== null && _g !== void 0 ? _g : '';
|
|
50
|
+
this.token_price_cache_seconds = cfg.token_price_cache_seconds;
|
|
51
|
+
this.token_market_price_url = (_h = cfg.token_market_price_url) !== null && _h !== void 0 ? _h : '';
|
|
52
|
+
this.wallet_dir = cfg.wallet_dir;
|
|
53
|
+
this.encryption_key = (_j = cfg.encryption_key) !== null && _j !== void 0 ? _j : '';
|
|
54
|
+
this.providers_file_path = cfg.providers_file_path;
|
|
55
|
+
this.fixed_symbol_address_file = (_k = cfg.fixed_symbol_address_file) !== null && _k !== void 0 ? _k : '';
|
|
56
|
+
this.zh_pinyin_map_file = (_l = cfg.zh_pinyin_map_file) !== null && _l !== void 0 ? _l : '';
|
|
57
|
+
this.alert_analyze_host = (_m = cfg.alert_analyze_host) !== null && _m !== void 0 ? _m : '';
|
|
58
|
+
this.alert_flush_size = cfg.alert_flush_size;
|
|
59
|
+
this.alert_flush_ms = cfg.alert_flush_ms;
|
|
60
|
+
this.alert_dedup_window_ms = cfg.alert_dedup_window_ms;
|
|
61
|
+
this.namespace = (_o = cfg.namespace) !== null && _o !== void 0 ? _o : '';
|
|
62
|
+
this.server_ip_list = (_p = cfg.server_ip_list) !== null && _p !== void 0 ? _p : '';
|
|
63
|
+
this.ip_exclude_prefix = (_q = cfg.ip_exclude_prefix) !== null && _q !== void 0 ? _q : '';
|
|
53
64
|
}
|
|
54
65
|
print(moduleName) {
|
|
55
|
-
|
|
56
|
-
for (const key of ENVARGS_KEYS) {
|
|
57
|
-
cfg[key] = this[key];
|
|
58
|
-
}
|
|
59
|
-
(0, env_loader_1.printEnvConfig)(moduleName || this.app_name || 'EnvArgs', cfg, ENVARGS_KEYS);
|
|
66
|
+
(0, env_loader_1.printEnvConfig)(moduleName || this.app_name || 'EnvArgs', this);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
exports.EnvArgs = EnvArgs;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setCoreEnv = setCoreEnv;
|
|
4
|
+
exports.getCoreEnv = getCoreEnv;
|
|
5
|
+
let _core_env;
|
|
6
|
+
function setCoreEnv(env) {
|
|
7
|
+
_core_env = env;
|
|
8
|
+
}
|
|
9
|
+
function getCoreEnv() {
|
|
10
|
+
if (!_core_env) {
|
|
11
|
+
throw new Error('CoreEnv 尚未初始化 — 应用入口处请 import 模块 app_config/index.ts(会自动 setCoreEnv),或显式调用 setCoreEnv(envArgs)');
|
|
12
|
+
}
|
|
13
|
+
return _core_env;
|
|
14
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function loadEnvConfig(
|
|
2
|
-
export declare function validateEnvConfig(
|
|
3
|
-
export declare function printEnvConfig(moduleName: string,
|
|
1
|
+
export declare function loadEnvConfig(overrides?: Record<string, any>): Record<string, any>;
|
|
2
|
+
export declare function validateEnvConfig(overrides?: Record<string, any>): string[];
|
|
3
|
+
export declare function printEnvConfig(moduleName: string, envArgs: Record<string, any>): void;
|
|
@@ -30,9 +30,8 @@ function getTypeDefault(type) {
|
|
|
30
30
|
default: return '';
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function loadEnvConfig(
|
|
34
|
-
|
|
35
|
-
const missing = validateEnvConfig(keys, overrides);
|
|
33
|
+
function loadEnvConfig(overrides) {
|
|
34
|
+
const missing = validateEnvConfig(overrides);
|
|
36
35
|
if (missing.length > 0) {
|
|
37
36
|
const header = '[EnvConfig] 以下必填环境变量未设置(进程拒绝启动):';
|
|
38
37
|
const detail = missing.map(m => ` - ${m}`).join('\n');
|
|
@@ -40,13 +39,7 @@ function loadEnvConfig(keys, overrides) {
|
|
|
40
39
|
}
|
|
41
40
|
const registry = (0, env_registry_1.getEnvRegistry)();
|
|
42
41
|
const config = {};
|
|
43
|
-
for (const key of
|
|
44
|
-
const def = registry[key];
|
|
45
|
-
if (!def) {
|
|
46
|
-
console.warn(`[EnvConfig] unknown key: ${key} (not registered)`);
|
|
47
|
-
config[key] = (_b = (_a = overrides === null || overrides === void 0 ? void 0 : overrides[key]) !== null && _a !== void 0 ? _a : process.env[key.toUpperCase()]) !== null && _b !== void 0 ? _b : '';
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
42
|
+
for (const [key, def] of Object.entries(registry)) {
|
|
50
43
|
if (overrides && key in overrides && overrides[key] !== undefined) {
|
|
51
44
|
config[key] = overrides[key];
|
|
52
45
|
}
|
|
@@ -56,13 +49,10 @@ function loadEnvConfig(keys, overrides) {
|
|
|
56
49
|
}
|
|
57
50
|
return config;
|
|
58
51
|
}
|
|
59
|
-
function validateEnvConfig(
|
|
52
|
+
function validateEnvConfig(overrides) {
|
|
60
53
|
const registry = (0, env_registry_1.getEnvRegistry)();
|
|
61
54
|
const missing = [];
|
|
62
|
-
for (const key of
|
|
63
|
-
const def = registry[key];
|
|
64
|
-
if (!def)
|
|
65
|
-
continue;
|
|
55
|
+
for (const [key, def] of Object.entries(registry)) {
|
|
66
56
|
const isRequired = def.required === true || !Object.prototype.hasOwnProperty.call(def, 'default');
|
|
67
57
|
if (!isRequired)
|
|
68
58
|
continue;
|
|
@@ -86,9 +76,10 @@ function maskValue(key, value, def) {
|
|
|
86
76
|
}
|
|
87
77
|
return str;
|
|
88
78
|
}
|
|
89
|
-
function printEnvConfig(moduleName,
|
|
79
|
+
function printEnvConfig(moduleName, envArgs) {
|
|
90
80
|
const registry = (0, env_registry_1.getEnvRegistry)();
|
|
91
81
|
const divider = '═'.repeat(70);
|
|
82
|
+
const keys = Object.keys(envArgs).filter(k => !k.startsWith('_') && typeof envArgs[k] !== 'function');
|
|
92
83
|
const lines = [];
|
|
93
84
|
lines.push('');
|
|
94
85
|
lines.push(divider);
|
|
@@ -101,7 +92,7 @@ function printEnvConfig(moduleName, config, keys) {
|
|
|
101
92
|
for (const key of keys) {
|
|
102
93
|
const def = registry[key];
|
|
103
94
|
const envName = def ? def.env : key.toUpperCase();
|
|
104
|
-
const val = maskValue(key,
|
|
95
|
+
const val = maskValue(key, envArgs[key], def);
|
|
105
96
|
const desc = (def === null || def === void 0 ? void 0 : def.desc) ? ` # ${def.desc}` : '';
|
|
106
97
|
lines.push(` ${envName.padEnd(maxKeyLen)} ${val}${desc}`);
|
|
107
98
|
}
|
|
@@ -14,31 +14,18 @@ registerEnvVars({
|
|
|
14
14
|
app_base_dir: { env: 'APP_BASE_DIR', type: 'string', default: '', desc: '应用根目录(诊断用,可选)' },
|
|
15
15
|
chain_id: { env: 'CHAIN_ID', type: 'string', required: true, desc: '链标识(BSC/SOLANA/TRON)' },
|
|
16
16
|
dex_id: { env: 'DEX_ID', type: 'string', default: '', desc: 'DEX 标识(业务进程用,可选)' },
|
|
17
|
+
log_level: { env: 'LOG_LEVEL', type: 'string', default: '', desc: '日志级别(TRACE/DEBUG/INFO/WARN/ERROR)' },
|
|
18
|
+
log_depth: { env: 'LOG_DEPTH', type: 'number', default: 4, desc: 'console.dir 深度' },
|
|
19
|
+
server_id: { env: 'SERVER_ID', type: 'string', default: '', desc: '服务器标识(用于 region/name 推断)' },
|
|
17
20
|
redis_host: { env: 'REDIS_HOST', type: 'string', default: '127.0.0.1', desc: 'Redis 地址' },
|
|
18
21
|
redis_port: { env: 'REDIS_PORT', type: 'number', default: 6379, desc: 'Redis 端口' },
|
|
19
|
-
config_center_host: { env: 'CONFIG_CENTER_HOST', type: 'string', default: '127.0.0.1', desc: 'config-center 主机(IP 或域名),不含端口;cache_* 拼 URL 时追加 SERVICE_PORT.CONFIG_CENTER_HTTP' },
|
|
20
|
-
trade_analyze_host: { env: 'TRADE_ANALYZE_HOST', type: 'string', default: '127.0.0.1', desc: 'analyze 地址(IP)' },
|
|
21
|
-
trade_mgt_host: { env: 'TRADE_MGT_HOST', type: 'string', default: '127.0.0.1', desc: 'trade-mgt 默认地址(IP),端口固定 SERVICE_PORT.TRADE_MGT_HTTP' },
|
|
22
|
-
trade_mgt_hosts: { env: 'TRADE_MGT_HOSTS', type: 'string', default: '', desc: 'trade-mgt 可选地址列表(IP逗号分隔),UI 可切换;未配置则使用 TRADE_MGT_HOST' },
|
|
23
|
-
alert_analyze_host: { env: 'ALERT_ANALYZE_HOST', type: 'string', default: '', desc: 'analyze 告警端点地址(IP),为空则不上报;默认 127.0.0.1' },
|
|
24
|
-
alert_analyze_port: { env: 'ALERT_ANALYZE_PORT', type: 'number', default: 8004, desc: 'analyze 告警端点端口' },
|
|
25
|
-
alert_flush_size: { env: 'ALERT_FLUSH_SIZE', type: 'number', default: 10, desc: 'alert 批处理阈值(条数)' },
|
|
26
|
-
alert_flush_ms: { env: 'ALERT_FLUSH_MS', type: 'number', default: 5000, desc: 'alert 批处理阈值(ms)' },
|
|
27
|
-
alert_dedup_window_ms: { env: 'ALERT_DEDUP_WINDOW_MS', type: 'number', default: 60000, desc: 'alert 去重窗口(ms)' },
|
|
28
|
-
analyze_sqlite_retain: { env: 'ANALYZE_SQLITE_RETAIN', type: 'string', default: '8h', desc: 'analyze SQLite 数据保留期,支持 8h/2d/30m 格式' },
|
|
29
|
-
alert_webhook_url: { env: 'ALERT_WEBHOOK_URL', type: 'string', default: '', sensitive: true, desc: '外推 webhook URL;为空则禁用外推' },
|
|
30
|
-
alert_webhook_type: { env: 'ALERT_WEBHOOK_TYPE', type: 'string', default: '', desc: 'webhook 类型(lark/slack/dingtalk/generic);省略则按 URL 自动识别' },
|
|
31
|
-
alert_webhook_min_severity: { env: 'ALERT_WEBHOOK_MIN_SEVERITY', type: 'string', default: 'critical', desc: '只外推 >= 此级别的告警(warn/error/critical)' },
|
|
32
|
-
alert_webhook_rate_limit: { env: 'ALERT_WEBHOOK_RATE_LIMIT', type: 'number', default: 10, desc: 'webhook 速率上限(条/分钟),防刷屏' },
|
|
33
|
-
alert_webhook_dedup_ms: { env: 'ALERT_WEBHOOK_DEDUP_MS', type: 'string', default: '5m', desc: 'webhook 去重窗口(同 code+source 不重复推),支持 5m/30s/1h' },
|
|
34
|
-
alert_webhook_system_label: { env: 'ALERT_WEBHOOK_SYSTEM_LABEL', type: 'string', default: '', desc: 'webhook 消息中显示的系统标识,省略时使用 CHAIN_ID' },
|
|
35
|
-
trade_analyze_port: { env: 'TRADE_ANALYZE_PORT', type: 'number', default: 8004, desc: 'analyze 端口' },
|
|
36
|
-
trade_analyze_url: { env: 'TRADE_ANALYZE_URL', type: 'string', default: '', desc: 'analyze URL(旧)' },
|
|
37
|
-
providers_file_path: { env: 'PROVIDERS_FILE_PATH', type: 'string', default: '', desc: '本地 stream-quote providers.json 绝对路径;Provider 增删改同步写入该文件(+ Redis + 广播)' },
|
|
38
22
|
rpc_endpoint: { env: 'RPC_ENDPOINT', type: 'string', default: '', desc: 'RPC HTTP 端点' },
|
|
39
23
|
ws_endpoint: { env: 'WS_ENDPOINT', type: 'string', default: '', desc: 'RPC WebSocket 端点' },
|
|
40
24
|
grpc_endpoint: { env: 'GRPC_ENDPOINT', type: 'string', default: '', desc: 'gRPC 端点' },
|
|
41
25
|
grpc_token: { env: 'GRPC_TOKEN', type: 'string', default: '', sensitive: true, desc: 'gRPC 认证 token' },
|
|
26
|
+
config_center_host: { env: 'CONFIG_CENTER_HOST', type: 'string', default: '127.0.0.1', desc: '配置中心' },
|
|
27
|
+
enable_init_cache: { env: 'ENABLE_INIT_CACHE', type: 'string', default: '', desc: '仅 config-center:是否初始化缓存(空或 true 视为启用;false 则跳过)' },
|
|
28
|
+
trade_analyze_host: { env: 'TRADE_ANALYZE_HOST', type: 'string', default: '', desc: 'analyze 上报地址(IP);为空则不上报' },
|
|
42
29
|
auto_quote_enable: { env: 'AUTO_QUOTE_ENABLE', type: 'boolean', default: false, desc: '自动报价开关' },
|
|
43
30
|
auto_quote_interval_mills: { env: 'AUTO_QUOTE_INTERVAL_MILLS', type: 'number', default: 60000, desc: '自动报价间隔(ms)' },
|
|
44
31
|
quote_pair: { env: 'QUOTE_PAIR', type: 'string', default: '', desc: '报价币对' },
|
|
@@ -46,8 +33,26 @@ registerEnvVars({
|
|
|
46
33
|
quote_pool_address: { env: 'QUOTE_POOL_ADDRESS', type: 'string', default: '', desc: '指定池子地址' },
|
|
47
34
|
quote_pool_name: { env: 'QUOTE_POOL_NAME', type: 'string', default: '', desc: '指定池子名称' },
|
|
48
35
|
quote_pool_fee_rate: { env: 'QUOTE_POOL_FEE_RATE', type: 'number', default: 0, desc: '指定池子费率' },
|
|
36
|
+
tick_cache_force_full_refresh_interval: { env: 'TICK_CACHE_FORCE_FULL_REFRESH_INTERVAL', type: 'number', default: 60000, desc: 'tick 流动性强制全量刷新间隔(ms)' },
|
|
37
|
+
depth_cex_bps: { env: 'DEPTH_CEX_BPS', type: 'number', default: 20, desc: 'CEX 深度 bps(用于报价转换)' },
|
|
38
|
+
group_id: { env: 'GROUP_ID', type: 'string', default: '', desc: '当前 trader 进程绑定的 group(与 TRADE_GROUP_ID 二选一;用于缓存隔离/事件过滤)' },
|
|
49
39
|
trade_group_id: { env: 'TRADE_GROUP_ID', type: 'string', default: '', desc: '交易组 ID' },
|
|
50
40
|
trade_pair: { env: 'TRADE_PAIR', type: 'string', default: '', desc: '交易币对' },
|
|
51
|
-
|
|
41
|
+
trade_log_report_cex_url: { env: 'TRADE_LOG_REPORT_CEX_URL', type: 'string', default: '', desc: '【使用方: ttd-core/src/index.ts save_trade_execution_logs】DEX 交易执行日志上报 cex 侧接收端 URL;为空则跳过上报' },
|
|
42
|
+
trade_log_report_cex_data_type: { env: 'TRADE_LOG_REPORT_CEX_DATA_TYPE', type: 'string', default: '', desc: '【使用方: ttd-core/src/index.ts save_trade_execution_logs】上报 payload.type,cex 侧用于路由/区分;为空则跳过上报' },
|
|
52
43
|
wallet_dir: { env: 'WALLET_DIR', type: 'string', default: '', desc: '钱包目录' },
|
|
44
|
+
encryption_key: { env: 'ENCRYPTION_KEY', type: 'string', default: '', sensitive: true, desc: '对称加密密钥(用于钱包文件等)' },
|
|
45
|
+
trade_analyze_url: { env: 'TRADE_ANALYZE_URL', type: 'string', default: '', desc: 'analyze HTTP 基址(旧 EnvArgs;未配则 analyze 上报走默认拼接)' },
|
|
46
|
+
providers_file_path: { env: 'PROVIDERS_FILE_PATH', type: 'string', default: '', desc: 'stream-quote providers.json 绝对路径;留空则仅写 Redis' },
|
|
47
|
+
token_price_cache_seconds: { env: 'TOKEN_PRICE_CACHE_SECONDS', type: 'number', default: 1200, desc: 'token 价格缓存时间(s)' },
|
|
48
|
+
token_market_price_url: { env: 'TOKEN_MARKET_PRICE_URL', type: 'string', default: '', desc: '【使用方: ttd-core estimate_token_amount】config-center 市价估算 HTTP 基址;为空则跳过远程回退' },
|
|
49
|
+
fixed_symbol_address_file: { env: 'FIXED_SYMBOL_ADDRESS_FILE', type: 'string', default: '', desc: '固定 symbol/address 映射文件路径(覆盖默认按 CHAIN_ID 推断的路径)' },
|
|
50
|
+
zh_pinyin_map_file: { env: 'ZH_PINYIN_MAP_FILE', type: 'string', default: '', desc: '中文拼音映射文件路径(覆盖默认路径)' },
|
|
51
|
+
server_ip_list: { env: 'SERVER_IP_LIST', type: 'string', default: '', desc: '服务器可用 IP 列表(逗号分隔);配置后优先使用;为空则从网卡探测并结合 IP_EXCLUDE_PREFIX 过滤' },
|
|
52
|
+
ip_exclude_prefix: { env: 'IP_EXCLUDE_PREFIX', type: 'string', default: '192.168', desc: 'IP 前缀排除列表(逗号分隔)' },
|
|
53
|
+
alert_analyze_host: { env: 'ALERT_ANALYZE_HOST', type: 'string', default: '', desc: 'alert ingest 地址(IP);为空则不上报' },
|
|
54
|
+
alert_flush_size: { env: 'ALERT_FLUSH_SIZE', type: 'number', default: 10, desc: 'alert 批处理阈值(条数)' },
|
|
55
|
+
alert_flush_ms: { env: 'ALERT_FLUSH_MS', type: 'number', default: 5000, desc: 'alert 批处理阈值(ms)' },
|
|
56
|
+
alert_dedup_window_ms: { env: 'ALERT_DEDUP_WINDOW_MS', type: 'number', default: 60000, desc: 'alert 去重窗口(ms)' },
|
|
57
|
+
namespace: { env: 'NAMESPACE', type: 'string', default: '', desc: '服务命名空间(用于日志/告警 source 前缀等)' },
|
|
53
58
|
});
|
package/dist/app_config/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./AppConfig"), exports);
|
|
|
20
20
|
__exportStar(require("./AbstractTradeAppConfig"), exports);
|
|
21
21
|
__exportStar(require("./env_registry"), exports);
|
|
22
22
|
__exportStar(require("./env_loader"), exports);
|
|
23
|
+
__exportStar(require("./core_env"), exports);
|
|
23
24
|
const getGlobalAppConfig = () => {
|
|
24
25
|
let app_config = global.app_config;
|
|
25
26
|
if (!app_config) {
|