@clonegod/ttd-core 3.1.18 → 3.1.20
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 -5
- package/dist/index.js +17 -47
- 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 +2 -2
- 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
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { RedisClientType } from "redis";
|
|
2
|
-
export declare class RedisClient {
|
|
3
|
-
redis_client: RedisClientType;
|
|
4
|
-
private lockPrefix;
|
|
5
|
-
private lockMaxRetries;
|
|
6
|
-
private lockRetryDelayMs;
|
|
7
|
-
private lockExpireSeconds;
|
|
8
|
-
constructor(lockPrefix?: string);
|
|
9
|
-
init(): Promise<void>;
|
|
10
|
-
private ensureClient;
|
|
11
|
-
exists(key: string): Promise<number>;
|
|
12
|
-
ttl(key: string): Promise<number>;
|
|
13
|
-
expire(key: string, ttl: number): Promise<boolean>;
|
|
14
|
-
del(key: string, field?: string): Promise<number>;
|
|
15
|
-
set_nx(key: string, value: string): Promise<boolean>;
|
|
16
|
-
get(key: string): Promise<string | null>;
|
|
17
|
-
set(key: string, value: string, expireSeconds?: number): Promise<string | null>;
|
|
18
|
-
hset(key: string, field: string, value: string, expireSeconds?: number): Promise<number>;
|
|
19
|
-
hget(key: string, field: string): Promise<string | undefined>;
|
|
20
|
-
hgetall(key: string): Promise<Record<string, string>>;
|
|
21
|
-
hmget(key: string, fields: string[]): Promise<(string | null)[]>;
|
|
22
|
-
hkeys(key: string): Promise<string[]>;
|
|
23
|
-
hdel(key: string, field: string): Promise<number>;
|
|
24
|
-
hlen(key: string): Promise<number>;
|
|
25
|
-
hinc(key: string, field: string, ttl?: number): Promise<number[]>;
|
|
26
|
-
lrange(key: string, start?: number, stop?: number): Promise<string[]>;
|
|
27
|
-
lpush(key: string, value: string): Promise<number>;
|
|
28
|
-
ltrim(key: string, start: number, stop: number): Promise<string>;
|
|
29
|
-
ping(): Promise<string>;
|
|
30
|
-
type(key: string): Promise<string>;
|
|
31
|
-
multi(): import("@redis/client/dist/lib/client/multi-command").RedisClientMultiCommandType<{
|
|
32
|
-
graph: {
|
|
33
|
-
CONFIG_GET: typeof import("@redis/graph/dist/commands/CONFIG_GET");
|
|
34
|
-
configGet: typeof import("@redis/graph/dist/commands/CONFIG_GET");
|
|
35
|
-
CONFIG_SET: typeof import("@redis/graph/dist/commands/CONFIG_SET");
|
|
36
|
-
configSet: typeof import("@redis/graph/dist/commands/CONFIG_SET");
|
|
37
|
-
DELETE: typeof import("@redis/graph/dist/commands/DELETE");
|
|
38
|
-
delete: typeof import("@redis/graph/dist/commands/DELETE");
|
|
39
|
-
EXPLAIN: typeof import("@redis/graph/dist/commands/EXPLAIN");
|
|
40
|
-
explain: typeof import("@redis/graph/dist/commands/EXPLAIN");
|
|
41
|
-
LIST: typeof import("@redis/graph/dist/commands/LIST");
|
|
42
|
-
list: typeof import("@redis/graph/dist/commands/LIST");
|
|
43
|
-
PROFILE: typeof import("@redis/graph/dist/commands/PROFILE");
|
|
44
|
-
profile: typeof import("@redis/graph/dist/commands/PROFILE");
|
|
45
|
-
QUERY: typeof import("@redis/graph/dist/commands/QUERY");
|
|
46
|
-
query: typeof import("@redis/graph/dist/commands/QUERY");
|
|
47
|
-
RO_QUERY: typeof import("@redis/graph/dist/commands/RO_QUERY");
|
|
48
|
-
roQuery: typeof import("@redis/graph/dist/commands/RO_QUERY");
|
|
49
|
-
SLOWLOG: typeof import("@redis/graph/dist/commands/SLOWLOG");
|
|
50
|
-
slowLog: typeof import("@redis/graph/dist/commands/SLOWLOG");
|
|
51
|
-
};
|
|
52
|
-
json: {
|
|
53
|
-
ARRAPPEND: typeof import("@redis/json/dist/commands/ARRAPPEND");
|
|
54
|
-
arrAppend: typeof import("@redis/json/dist/commands/ARRAPPEND");
|
|
55
|
-
ARRINDEX: typeof import("@redis/json/dist/commands/ARRINDEX");
|
|
56
|
-
arrIndex: typeof import("@redis/json/dist/commands/ARRINDEX");
|
|
57
|
-
ARRINSERT: typeof import("@redis/json/dist/commands/ARRINSERT");
|
|
58
|
-
arrInsert: typeof import("@redis/json/dist/commands/ARRINSERT");
|
|
59
|
-
ARRLEN: typeof import("@redis/json/dist/commands/ARRLEN");
|
|
60
|
-
arrLen: typeof import("@redis/json/dist/commands/ARRLEN");
|
|
61
|
-
ARRPOP: typeof import("@redis/json/dist/commands/ARRPOP");
|
|
62
|
-
arrPop: typeof import("@redis/json/dist/commands/ARRPOP");
|
|
63
|
-
ARRTRIM: typeof import("@redis/json/dist/commands/ARRTRIM");
|
|
64
|
-
arrTrim: typeof import("@redis/json/dist/commands/ARRTRIM");
|
|
65
|
-
DEBUG_MEMORY: typeof import("@redis/json/dist/commands/DEBUG_MEMORY");
|
|
66
|
-
debugMemory: typeof import("@redis/json/dist/commands/DEBUG_MEMORY");
|
|
67
|
-
DEL: typeof import("@redis/json/dist/commands/DEL");
|
|
68
|
-
del: typeof import("@redis/json/dist/commands/DEL");
|
|
69
|
-
FORGET: typeof import("@redis/json/dist/commands/FORGET");
|
|
70
|
-
forget: typeof import("@redis/json/dist/commands/FORGET");
|
|
71
|
-
GET: typeof import("@redis/json/dist/commands/GET");
|
|
72
|
-
get: typeof import("@redis/json/dist/commands/GET");
|
|
73
|
-
MERGE: typeof import("@redis/json/dist/commands/MERGE");
|
|
74
|
-
merge: typeof import("@redis/json/dist/commands/MERGE");
|
|
75
|
-
MGET: typeof import("@redis/json/dist/commands/MGET");
|
|
76
|
-
mGet: typeof import("@redis/json/dist/commands/MGET");
|
|
77
|
-
MSET: typeof import("@redis/json/dist/commands/MSET");
|
|
78
|
-
mSet: typeof import("@redis/json/dist/commands/MSET");
|
|
79
|
-
NUMINCRBY: typeof import("@redis/json/dist/commands/NUMINCRBY");
|
|
80
|
-
numIncrBy: typeof import("@redis/json/dist/commands/NUMINCRBY");
|
|
81
|
-
NUMMULTBY: typeof import("@redis/json/dist/commands/NUMMULTBY");
|
|
82
|
-
numMultBy: typeof import("@redis/json/dist/commands/NUMMULTBY");
|
|
83
|
-
OBJKEYS: typeof import("@redis/json/dist/commands/OBJKEYS");
|
|
84
|
-
objKeys: typeof import("@redis/json/dist/commands/OBJKEYS");
|
|
85
|
-
OBJLEN: typeof import("@redis/json/dist/commands/OBJLEN");
|
|
86
|
-
objLen: typeof import("@redis/json/dist/commands/OBJLEN");
|
|
87
|
-
RESP: typeof import("@redis/json/dist/commands/RESP");
|
|
88
|
-
resp: typeof import("@redis/json/dist/commands/RESP");
|
|
89
|
-
SET: typeof import("@redis/json/dist/commands/SET");
|
|
90
|
-
set: typeof import("@redis/json/dist/commands/SET");
|
|
91
|
-
STRAPPEND: typeof import("@redis/json/dist/commands/STRAPPEND");
|
|
92
|
-
strAppend: typeof import("@redis/json/dist/commands/STRAPPEND");
|
|
93
|
-
STRLEN: typeof import("@redis/json/dist/commands/STRLEN");
|
|
94
|
-
strLen: typeof import("@redis/json/dist/commands/STRLEN");
|
|
95
|
-
TYPE: typeof import("@redis/json/dist/commands/TYPE");
|
|
96
|
-
type: typeof import("@redis/json/dist/commands/TYPE");
|
|
97
|
-
};
|
|
98
|
-
ft: {
|
|
99
|
-
_LIST: typeof import("@redis/search/dist/commands/_LIST");
|
|
100
|
-
_list: typeof import("@redis/search/dist/commands/_LIST");
|
|
101
|
-
ALTER: typeof import("@redis/search/dist/commands/ALTER");
|
|
102
|
-
alter: typeof import("@redis/search/dist/commands/ALTER");
|
|
103
|
-
AGGREGATE_WITHCURSOR: typeof import("@redis/search/dist/commands/AGGREGATE_WITHCURSOR");
|
|
104
|
-
aggregateWithCursor: typeof import("@redis/search/dist/commands/AGGREGATE_WITHCURSOR");
|
|
105
|
-
AGGREGATE: typeof import("@redis/search/dist/commands/AGGREGATE");
|
|
106
|
-
aggregate: typeof import("@redis/search/dist/commands/AGGREGATE");
|
|
107
|
-
ALIASADD: typeof import("@redis/search/dist/commands/ALIASADD");
|
|
108
|
-
aliasAdd: typeof import("@redis/search/dist/commands/ALIASADD");
|
|
109
|
-
ALIASDEL: typeof import("@redis/search/dist/commands/ALIASDEL");
|
|
110
|
-
aliasDel: typeof import("@redis/search/dist/commands/ALIASDEL");
|
|
111
|
-
ALIASUPDATE: typeof import("@redis/search/dist/commands/ALIASUPDATE");
|
|
112
|
-
aliasUpdate: typeof import("@redis/search/dist/commands/ALIASUPDATE");
|
|
113
|
-
CONFIG_GET: typeof import("@redis/search/dist/commands/CONFIG_GET");
|
|
114
|
-
configGet: typeof import("@redis/search/dist/commands/CONFIG_GET");
|
|
115
|
-
CONFIG_SET: typeof import("@redis/search/dist/commands/CONFIG_SET");
|
|
116
|
-
configSet: typeof import("@redis/search/dist/commands/CONFIG_SET");
|
|
117
|
-
CREATE: typeof import("@redis/search/dist/commands/CREATE");
|
|
118
|
-
create: typeof import("@redis/search/dist/commands/CREATE");
|
|
119
|
-
CURSOR_DEL: typeof import("@redis/search/dist/commands/CURSOR_DEL");
|
|
120
|
-
cursorDel: typeof import("@redis/search/dist/commands/CURSOR_DEL");
|
|
121
|
-
CURSOR_READ: typeof import("@redis/search/dist/commands/CURSOR_READ");
|
|
122
|
-
cursorRead: typeof import("@redis/search/dist/commands/CURSOR_READ");
|
|
123
|
-
DICTADD: typeof import("@redis/search/dist/commands/DICTADD");
|
|
124
|
-
dictAdd: typeof import("@redis/search/dist/commands/DICTADD");
|
|
125
|
-
DICTDEL: typeof import("@redis/search/dist/commands/DICTDEL");
|
|
126
|
-
dictDel: typeof import("@redis/search/dist/commands/DICTDEL");
|
|
127
|
-
DICTDUMP: typeof import("@redis/search/dist/commands/DICTDUMP");
|
|
128
|
-
dictDump: typeof import("@redis/search/dist/commands/DICTDUMP");
|
|
129
|
-
DROPINDEX: typeof import("@redis/search/dist/commands/DROPINDEX");
|
|
130
|
-
dropIndex: typeof import("@redis/search/dist/commands/DROPINDEX");
|
|
131
|
-
EXPLAIN: typeof import("@redis/search/dist/commands/EXPLAIN");
|
|
132
|
-
explain: typeof import("@redis/search/dist/commands/EXPLAIN");
|
|
133
|
-
EXPLAINCLI: typeof import("@redis/search/dist/commands/EXPLAINCLI");
|
|
134
|
-
explainCli: typeof import("@redis/search/dist/commands/EXPLAINCLI");
|
|
135
|
-
INFO: typeof import("@redis/search/dist/commands/INFO");
|
|
136
|
-
info: typeof import("@redis/search/dist/commands/INFO");
|
|
137
|
-
PROFILESEARCH: typeof import("@redis/search/dist/commands/PROFILE_SEARCH");
|
|
138
|
-
profileSearch: typeof import("@redis/search/dist/commands/PROFILE_SEARCH");
|
|
139
|
-
PROFILEAGGREGATE: typeof import("@redis/search/dist/commands/PROFILE_AGGREGATE");
|
|
140
|
-
profileAggregate: typeof import("@redis/search/dist/commands/PROFILE_AGGREGATE");
|
|
141
|
-
SEARCH: typeof import("@redis/search/dist/commands/SEARCH");
|
|
142
|
-
search: typeof import("@redis/search/dist/commands/SEARCH");
|
|
143
|
-
SEARCH_NOCONTENT: typeof import("@redis/search/dist/commands/SEARCH_NOCONTENT");
|
|
144
|
-
searchNoContent: typeof import("@redis/search/dist/commands/SEARCH_NOCONTENT");
|
|
145
|
-
SPELLCHECK: typeof import("@redis/search/dist/commands/SPELLCHECK");
|
|
146
|
-
spellCheck: typeof import("@redis/search/dist/commands/SPELLCHECK");
|
|
147
|
-
SUGADD: typeof import("@redis/search/dist/commands/SUGADD");
|
|
148
|
-
sugAdd: typeof import("@redis/search/dist/commands/SUGADD");
|
|
149
|
-
SUGDEL: typeof import("@redis/search/dist/commands/SUGDEL");
|
|
150
|
-
sugDel: typeof import("@redis/search/dist/commands/SUGDEL");
|
|
151
|
-
SUGGET_WITHPAYLOADS: typeof import("@redis/search/dist/commands/SUGGET_WITHPAYLOADS");
|
|
152
|
-
sugGetWithPayloads: typeof import("@redis/search/dist/commands/SUGGET_WITHPAYLOADS");
|
|
153
|
-
SUGGET_WITHSCORES_WITHPAYLOADS: typeof import("@redis/search/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS");
|
|
154
|
-
sugGetWithScoresWithPayloads: typeof import("@redis/search/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS");
|
|
155
|
-
SUGGET_WITHSCORES: typeof import("@redis/search/dist/commands/SUGGET_WITHSCORES");
|
|
156
|
-
sugGetWithScores: typeof import("@redis/search/dist/commands/SUGGET_WITHSCORES");
|
|
157
|
-
SUGGET: typeof import("@redis/search/dist/commands/SUGGET");
|
|
158
|
-
sugGet: typeof import("@redis/search/dist/commands/SUGGET");
|
|
159
|
-
SUGLEN: typeof import("@redis/search/dist/commands/SUGLEN");
|
|
160
|
-
sugLen: typeof import("@redis/search/dist/commands/SUGLEN");
|
|
161
|
-
SYNDUMP: typeof import("@redis/search/dist/commands/SYNDUMP");
|
|
162
|
-
synDump: typeof import("@redis/search/dist/commands/SYNDUMP");
|
|
163
|
-
SYNUPDATE: typeof import("@redis/search/dist/commands/SYNUPDATE");
|
|
164
|
-
synUpdate: typeof import("@redis/search/dist/commands/SYNUPDATE");
|
|
165
|
-
TAGVALS: typeof import("@redis/search/dist/commands/TAGVALS");
|
|
166
|
-
tagVals: typeof import("@redis/search/dist/commands/TAGVALS");
|
|
167
|
-
};
|
|
168
|
-
ts: {
|
|
169
|
-
ADD: typeof import("@redis/time-series/dist/commands/ADD");
|
|
170
|
-
add: typeof import("@redis/time-series/dist/commands/ADD");
|
|
171
|
-
ALTER: typeof import("@redis/time-series/dist/commands/ALTER");
|
|
172
|
-
alter: typeof import("@redis/time-series/dist/commands/ALTER");
|
|
173
|
-
CREATE: typeof import("@redis/time-series/dist/commands/CREATE");
|
|
174
|
-
create: typeof import("@redis/time-series/dist/commands/CREATE");
|
|
175
|
-
CREATERULE: typeof import("@redis/time-series/dist/commands/CREATERULE");
|
|
176
|
-
createRule: typeof import("@redis/time-series/dist/commands/CREATERULE");
|
|
177
|
-
DECRBY: typeof import("@redis/time-series/dist/commands/DECRBY");
|
|
178
|
-
decrBy: typeof import("@redis/time-series/dist/commands/DECRBY");
|
|
179
|
-
DEL: typeof import("@redis/time-series/dist/commands/DEL");
|
|
180
|
-
del: typeof import("@redis/time-series/dist/commands/DEL");
|
|
181
|
-
DELETERULE: typeof import("@redis/time-series/dist/commands/DELETERULE");
|
|
182
|
-
deleteRule: typeof import("@redis/time-series/dist/commands/DELETERULE");
|
|
183
|
-
GET: typeof import("@redis/time-series/dist/commands/GET");
|
|
184
|
-
get: typeof import("@redis/time-series/dist/commands/GET");
|
|
185
|
-
INCRBY: typeof import("@redis/time-series/dist/commands/INCRBY");
|
|
186
|
-
incrBy: typeof import("@redis/time-series/dist/commands/INCRBY");
|
|
187
|
-
INFO_DEBUG: typeof import("@redis/time-series/dist/commands/INFO_DEBUG");
|
|
188
|
-
infoDebug: typeof import("@redis/time-series/dist/commands/INFO_DEBUG");
|
|
189
|
-
INFO: typeof import("@redis/time-series/dist/commands/INFO");
|
|
190
|
-
info: typeof import("@redis/time-series/dist/commands/INFO");
|
|
191
|
-
MADD: typeof import("@redis/time-series/dist/commands/MADD");
|
|
192
|
-
mAdd: typeof import("@redis/time-series/dist/commands/MADD");
|
|
193
|
-
MGET: typeof import("@redis/time-series/dist/commands/MGET");
|
|
194
|
-
mGet: typeof import("@redis/time-series/dist/commands/MGET");
|
|
195
|
-
MGET_WITHLABELS: typeof import("@redis/time-series/dist/commands/MGET_WITHLABELS");
|
|
196
|
-
mGetWithLabels: typeof import("@redis/time-series/dist/commands/MGET_WITHLABELS");
|
|
197
|
-
QUERYINDEX: typeof import("@redis/time-series/dist/commands/QUERYINDEX");
|
|
198
|
-
queryIndex: typeof import("@redis/time-series/dist/commands/QUERYINDEX");
|
|
199
|
-
RANGE: typeof import("@redis/time-series/dist/commands/RANGE");
|
|
200
|
-
range: typeof import("@redis/time-series/dist/commands/RANGE");
|
|
201
|
-
REVRANGE: typeof import("@redis/time-series/dist/commands/REVRANGE");
|
|
202
|
-
revRange: typeof import("@redis/time-series/dist/commands/REVRANGE");
|
|
203
|
-
MRANGE: typeof import("@redis/time-series/dist/commands/MRANGE");
|
|
204
|
-
mRange: typeof import("@redis/time-series/dist/commands/MRANGE");
|
|
205
|
-
MRANGE_WITHLABELS: typeof import("@redis/time-series/dist/commands/MRANGE_WITHLABELS");
|
|
206
|
-
mRangeWithLabels: typeof import("@redis/time-series/dist/commands/MRANGE_WITHLABELS");
|
|
207
|
-
MREVRANGE: typeof import("@redis/time-series/dist/commands/MREVRANGE");
|
|
208
|
-
mRevRange: typeof import("@redis/time-series/dist/commands/MREVRANGE");
|
|
209
|
-
MREVRANGE_WITHLABELS: typeof import("@redis/time-series/dist/commands/MREVRANGE_WITHLABELS");
|
|
210
|
-
mRevRangeWithLabels: typeof import("@redis/time-series/dist/commands/MREVRANGE_WITHLABELS");
|
|
211
|
-
};
|
|
212
|
-
bf: {
|
|
213
|
-
ADD: typeof import("@redis/bloom/dist/commands/bloom/ADD");
|
|
214
|
-
add: typeof import("@redis/bloom/dist/commands/bloom/ADD");
|
|
215
|
-
CARD: typeof import("@redis/bloom/dist/commands/bloom/CARD");
|
|
216
|
-
card: typeof import("@redis/bloom/dist/commands/bloom/CARD");
|
|
217
|
-
EXISTS: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
|
|
218
|
-
exists: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
|
|
219
|
-
INFO: typeof import("@redis/bloom/dist/commands/bloom/INFO");
|
|
220
|
-
info: typeof import("@redis/bloom/dist/commands/bloom/INFO");
|
|
221
|
-
INSERT: typeof import("@redis/bloom/dist/commands/bloom/INSERT");
|
|
222
|
-
insert: typeof import("@redis/bloom/dist/commands/bloom/INSERT");
|
|
223
|
-
LOADCHUNK: typeof import("@redis/bloom/dist/commands/bloom/LOADCHUNK");
|
|
224
|
-
loadChunk: typeof import("@redis/bloom/dist/commands/bloom/LOADCHUNK");
|
|
225
|
-
MADD: typeof import("@redis/bloom/dist/commands/bloom/MADD");
|
|
226
|
-
mAdd: typeof import("@redis/bloom/dist/commands/bloom/MADD");
|
|
227
|
-
MEXISTS: typeof import("@redis/bloom/dist/commands/bloom/MEXISTS");
|
|
228
|
-
mExists: typeof import("@redis/bloom/dist/commands/bloom/MEXISTS");
|
|
229
|
-
RESERVE: typeof import("@redis/bloom/dist/commands/bloom/RESERVE");
|
|
230
|
-
reserve: typeof import("@redis/bloom/dist/commands/bloom/RESERVE");
|
|
231
|
-
SCANDUMP: typeof import("@redis/bloom/dist/commands/bloom/SCANDUMP");
|
|
232
|
-
scanDump: typeof import("@redis/bloom/dist/commands/bloom/SCANDUMP");
|
|
233
|
-
};
|
|
234
|
-
cms: {
|
|
235
|
-
INCRBY: typeof import("@redis/bloom/dist/commands/count-min-sketch/INCRBY");
|
|
236
|
-
incrBy: typeof import("@redis/bloom/dist/commands/count-min-sketch/INCRBY");
|
|
237
|
-
INFO: typeof import("@redis/bloom/dist/commands/count-min-sketch/INFO");
|
|
238
|
-
info: typeof import("@redis/bloom/dist/commands/count-min-sketch/INFO");
|
|
239
|
-
INITBYDIM: typeof import("@redis/bloom/dist/commands/count-min-sketch/INITBYDIM");
|
|
240
|
-
initByDim: typeof import("@redis/bloom/dist/commands/count-min-sketch/INITBYDIM");
|
|
241
|
-
INITBYPROB: typeof import("@redis/bloom/dist/commands/count-min-sketch/INITBYPROB");
|
|
242
|
-
initByProb: typeof import("@redis/bloom/dist/commands/count-min-sketch/INITBYPROB");
|
|
243
|
-
MERGE: typeof import("@redis/bloom/dist/commands/count-min-sketch/MERGE");
|
|
244
|
-
merge: typeof import("@redis/bloom/dist/commands/count-min-sketch/MERGE");
|
|
245
|
-
QUERY: typeof import("@redis/bloom/dist/commands/count-min-sketch/QUERY");
|
|
246
|
-
query: typeof import("@redis/bloom/dist/commands/count-min-sketch/QUERY");
|
|
247
|
-
};
|
|
248
|
-
cf: {
|
|
249
|
-
ADD: typeof import("@redis/bloom/dist/commands/cuckoo/ADD");
|
|
250
|
-
add: typeof import("@redis/bloom/dist/commands/cuckoo/ADD");
|
|
251
|
-
ADDNX: typeof import("@redis/bloom/dist/commands/cuckoo/ADDNX");
|
|
252
|
-
addNX: typeof import("@redis/bloom/dist/commands/cuckoo/ADDNX");
|
|
253
|
-
COUNT: typeof import("@redis/bloom/dist/commands/cuckoo/COUNT");
|
|
254
|
-
count: typeof import("@redis/bloom/dist/commands/cuckoo/COUNT");
|
|
255
|
-
DEL: typeof import("@redis/bloom/dist/commands/cuckoo/DEL");
|
|
256
|
-
del: typeof import("@redis/bloom/dist/commands/cuckoo/DEL");
|
|
257
|
-
EXISTS: typeof import("@redis/bloom/dist/commands/cuckoo/EXISTS");
|
|
258
|
-
exists: typeof import("@redis/bloom/dist/commands/cuckoo/EXISTS");
|
|
259
|
-
INFO: typeof import("@redis/bloom/dist/commands/cuckoo/INFO");
|
|
260
|
-
info: typeof import("@redis/bloom/dist/commands/cuckoo/INFO");
|
|
261
|
-
INSERT: typeof import("@redis/bloom/dist/commands/cuckoo/INSERT");
|
|
262
|
-
insert: typeof import("@redis/bloom/dist/commands/cuckoo/INSERT");
|
|
263
|
-
INSERTNX: typeof import("@redis/bloom/dist/commands/cuckoo/INSERTNX");
|
|
264
|
-
insertNX: typeof import("@redis/bloom/dist/commands/cuckoo/INSERTNX");
|
|
265
|
-
LOADCHUNK: typeof import("@redis/bloom/dist/commands/cuckoo/LOADCHUNK");
|
|
266
|
-
loadChunk: typeof import("@redis/bloom/dist/commands/cuckoo/LOADCHUNK");
|
|
267
|
-
RESERVE: typeof import("@redis/bloom/dist/commands/cuckoo/RESERVE");
|
|
268
|
-
reserve: typeof import("@redis/bloom/dist/commands/cuckoo/RESERVE");
|
|
269
|
-
SCANDUMP: typeof import("@redis/bloom/dist/commands/cuckoo/SCANDUMP");
|
|
270
|
-
scanDump: typeof import("@redis/bloom/dist/commands/cuckoo/SCANDUMP");
|
|
271
|
-
};
|
|
272
|
-
tDigest: {
|
|
273
|
-
ADD: typeof import("@redis/bloom/dist/commands/t-digest/ADD");
|
|
274
|
-
add: typeof import("@redis/bloom/dist/commands/t-digest/ADD");
|
|
275
|
-
BYRANK: typeof import("@redis/bloom/dist/commands/t-digest/BYRANK");
|
|
276
|
-
byRank: typeof import("@redis/bloom/dist/commands/t-digest/BYRANK");
|
|
277
|
-
BYREVRANK: typeof import("@redis/bloom/dist/commands/t-digest/BYREVRANK");
|
|
278
|
-
byRevRank: typeof import("@redis/bloom/dist/commands/t-digest/BYREVRANK");
|
|
279
|
-
CDF: typeof import("@redis/bloom/dist/commands/t-digest/CDF");
|
|
280
|
-
cdf: typeof import("@redis/bloom/dist/commands/t-digest/CDF");
|
|
281
|
-
CREATE: typeof import("@redis/bloom/dist/commands/t-digest/CREATE");
|
|
282
|
-
create: typeof import("@redis/bloom/dist/commands/t-digest/CREATE");
|
|
283
|
-
INFO: typeof import("@redis/bloom/dist/commands/t-digest/INFO");
|
|
284
|
-
info: typeof import("@redis/bloom/dist/commands/t-digest/INFO");
|
|
285
|
-
MAX: typeof import("@redis/bloom/dist/commands/t-digest/MAX");
|
|
286
|
-
max: typeof import("@redis/bloom/dist/commands/t-digest/MAX");
|
|
287
|
-
MERGE: typeof import("@redis/bloom/dist/commands/t-digest/MERGE");
|
|
288
|
-
merge: typeof import("@redis/bloom/dist/commands/t-digest/MERGE");
|
|
289
|
-
MIN: typeof import("@redis/bloom/dist/commands/t-digest/MIN");
|
|
290
|
-
min: typeof import("@redis/bloom/dist/commands/t-digest/MIN");
|
|
291
|
-
QUANTILE: typeof import("@redis/bloom/dist/commands/t-digest/QUANTILE");
|
|
292
|
-
quantile: typeof import("@redis/bloom/dist/commands/t-digest/QUANTILE");
|
|
293
|
-
RANK: typeof import("@redis/bloom/dist/commands/t-digest/RANK");
|
|
294
|
-
rank: typeof import("@redis/bloom/dist/commands/t-digest/RANK");
|
|
295
|
-
RESET: typeof import("@redis/bloom/dist/commands/t-digest/RESET");
|
|
296
|
-
reset: typeof import("@redis/bloom/dist/commands/t-digest/RESET");
|
|
297
|
-
REVRANK: typeof import("@redis/bloom/dist/commands/t-digest/REVRANK");
|
|
298
|
-
revRank: typeof import("@redis/bloom/dist/commands/t-digest/REVRANK");
|
|
299
|
-
TRIMMED_MEAN: typeof import("@redis/bloom/dist/commands/t-digest/TRIMMED_MEAN");
|
|
300
|
-
trimmedMean: typeof import("@redis/bloom/dist/commands/t-digest/TRIMMED_MEAN");
|
|
301
|
-
};
|
|
302
|
-
topK: {
|
|
303
|
-
ADD: typeof import("@redis/bloom/dist/commands/top-k/ADD");
|
|
304
|
-
add: typeof import("@redis/bloom/dist/commands/top-k/ADD");
|
|
305
|
-
COUNT: typeof import("@redis/bloom/dist/commands/top-k/COUNT");
|
|
306
|
-
count: typeof import("@redis/bloom/dist/commands/top-k/COUNT");
|
|
307
|
-
INCRBY: typeof import("@redis/bloom/dist/commands/top-k/INCRBY");
|
|
308
|
-
incrBy: typeof import("@redis/bloom/dist/commands/top-k/INCRBY");
|
|
309
|
-
INFO: typeof import("@redis/bloom/dist/commands/top-k/INFO");
|
|
310
|
-
info: typeof import("@redis/bloom/dist/commands/top-k/INFO");
|
|
311
|
-
LIST_WITHCOUNT: typeof import("@redis/bloom/dist/commands/top-k/LIST_WITHCOUNT");
|
|
312
|
-
listWithCount: typeof import("@redis/bloom/dist/commands/top-k/LIST_WITHCOUNT");
|
|
313
|
-
LIST: typeof import("@redis/bloom/dist/commands/top-k/LIST");
|
|
314
|
-
list: typeof import("@redis/bloom/dist/commands/top-k/LIST");
|
|
315
|
-
QUERY: typeof import("@redis/bloom/dist/commands/top-k/QUERY");
|
|
316
|
-
query: typeof import("@redis/bloom/dist/commands/top-k/QUERY");
|
|
317
|
-
RESERVE: typeof import("@redis/bloom/dist/commands/top-k/RESERVE");
|
|
318
|
-
reserve: typeof import("@redis/bloom/dist/commands/top-k/RESERVE");
|
|
319
|
-
};
|
|
320
|
-
}, Record<string, never>, Record<string, never>>;
|
|
321
|
-
private getLockKey;
|
|
322
|
-
acquireLock(lock_key: string, lock_value: string, expireSeconds?: number): Promise<boolean>;
|
|
323
|
-
releaseLock(lock_key: string, lock_value: string): Promise<boolean>;
|
|
324
|
-
withLock<T>(lock_identifier: string, callback: () => Promise<T>, release_lock_delay_ms?: number): Promise<T>;
|
|
325
|
-
subscribe(channel: string, listener: any): Promise<void>;
|
|
326
|
-
publish(channel: string, message: string): Promise<void>;
|
|
327
|
-
}
|
|
328
|
-
export declare const RedisCommand: typeof RedisClient;
|
package/dist/cache/redis_cmd.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RedisCommand = exports.RedisClient = void 0;
|
|
13
|
-
const index_1 = require("../index");
|
|
14
|
-
const redis_client_1 = require("./redis_client");
|
|
15
|
-
const MAX_SUBSCRIBE_RECONNECT = 10;
|
|
16
|
-
class RedisClient {
|
|
17
|
-
constructor(lockPrefix = '') {
|
|
18
|
-
this.lockMaxRetries = 10;
|
|
19
|
-
this.lockRetryDelayMs = 300;
|
|
20
|
-
this.lockExpireSeconds = 3;
|
|
21
|
-
this.lockPrefix = lockPrefix;
|
|
22
|
-
}
|
|
23
|
-
init() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
this.redis_client = yield (0, redis_client_1.getRedisClient)('RedisClient');
|
|
26
|
-
(0, index_1.log_info)('[RedisClient] init done');
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
ensureClient() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (!this.redis_client) {
|
|
32
|
-
this.redis_client = yield (0, redis_client_1.getRedisClient)('RedisClient');
|
|
33
|
-
}
|
|
34
|
-
return this.redis_client;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exists(key) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
return yield this.redis_client.exists(key);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
ttl(key) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return yield this.redis_client.ttl(key);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
expire(key, ttl) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return yield this.redis_client.expire(key, ttl);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
del(key_1) {
|
|
53
|
-
return __awaiter(this, arguments, void 0, function* (key, field = '') {
|
|
54
|
-
if (field) {
|
|
55
|
-
return yield this.redis_client.hDel(key, field);
|
|
56
|
-
}
|
|
57
|
-
return yield this.redis_client.del(key);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
set_nx(key, value) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
return yield this.redis_client.setNX(key, value);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
get(key) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const client = yield this.ensureClient();
|
|
68
|
-
return yield client.get(key);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
set(key, value, expireSeconds) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const client = yield this.ensureClient();
|
|
74
|
-
if (expireSeconds && expireSeconds > 0) {
|
|
75
|
-
return yield client.set(key, value, { EX: expireSeconds });
|
|
76
|
-
}
|
|
77
|
-
return yield client.set(key, value);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
hset(key, field, value, expireSeconds) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const client = yield this.ensureClient();
|
|
83
|
-
const res = yield client.hSet(key, field, value);
|
|
84
|
-
if (expireSeconds && expireSeconds > 0) {
|
|
85
|
-
try {
|
|
86
|
-
yield client.hExpire(key, field, expireSeconds);
|
|
87
|
-
}
|
|
88
|
-
catch (_) {
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return res;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
hget(key, field) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const client = yield this.ensureClient();
|
|
97
|
-
return yield client.hGet(key, field);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
hgetall(key) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const client = yield this.ensureClient();
|
|
103
|
-
return yield client.hGetAll(key);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
hmget(key, fields) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const client = yield this.ensureClient();
|
|
109
|
-
return yield client.hmGet(key, fields);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
hkeys(key) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const client = yield this.ensureClient();
|
|
115
|
-
return yield client.hKeys(key);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
hdel(key, field) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const client = yield this.ensureClient();
|
|
121
|
-
return yield client.hDel(key, field);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
hlen(key) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const client = yield this.ensureClient();
|
|
127
|
-
return yield client.hLen(key);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
hinc(key_1, field_1) {
|
|
131
|
-
return __awaiter(this, arguments, void 0, function* (key, field, ttl = 3600) {
|
|
132
|
-
let res = [];
|
|
133
|
-
let res1 = yield this.redis_client.hIncrBy(key, field, 1);
|
|
134
|
-
res.push(res1);
|
|
135
|
-
if (ttl > 0) {
|
|
136
|
-
let res2 = yield this.redis_client.hExpire(key, field, ttl);
|
|
137
|
-
res.push(res2);
|
|
138
|
-
}
|
|
139
|
-
return res;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
lrange(key_1) {
|
|
143
|
-
return __awaiter(this, arguments, void 0, function* (key, start = 0, stop = -1) {
|
|
144
|
-
const client = yield this.ensureClient();
|
|
145
|
-
return yield client.lRange(key, start, stop);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
lpush(key, value) {
|
|
149
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
const client = yield this.ensureClient();
|
|
151
|
-
return yield client.lPush(key, value);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
ltrim(key, start, stop) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const client = yield this.ensureClient();
|
|
157
|
-
return yield client.lTrim(key, start, stop);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
ping() {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const client = yield this.ensureClient();
|
|
163
|
-
return yield client.ping();
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
type(key) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const client = yield this.ensureClient();
|
|
169
|
-
return yield client.type(key);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
multi() {
|
|
173
|
-
return this.redis_client.multi();
|
|
174
|
-
}
|
|
175
|
-
getLockKey(lock_identifier) {
|
|
176
|
-
return `${this.lockPrefix}:lock:${lock_identifier}`;
|
|
177
|
-
}
|
|
178
|
-
acquireLock(lock_key_1, lock_value_1) {
|
|
179
|
-
return __awaiter(this, arguments, void 0, function* (lock_key, lock_value, expireSeconds = this.lockExpireSeconds) {
|
|
180
|
-
const client = yield this.ensureClient();
|
|
181
|
-
const result = yield client.set(lock_key, lock_value, {
|
|
182
|
-
NX: true,
|
|
183
|
-
EX: expireSeconds,
|
|
184
|
-
});
|
|
185
|
-
(0, index_1.log_info)(`[Lock] try acquire: key=${lock_key}, value=${lock_value}, expire=${expireSeconds}s, result=${result}`);
|
|
186
|
-
return result === 'OK';
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
releaseLock(lock_key, lock_value) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const client = yield this.ensureClient();
|
|
192
|
-
const script = `
|
|
193
|
-
if redis.call('get', KEYS[1]) == ARGV[1] then
|
|
194
|
-
return redis.call('del', KEYS[1])
|
|
195
|
-
else
|
|
196
|
-
return 0
|
|
197
|
-
end
|
|
198
|
-
`;
|
|
199
|
-
const result = yield client.eval(script, {
|
|
200
|
-
keys: [lock_key],
|
|
201
|
-
arguments: [lock_value],
|
|
202
|
-
});
|
|
203
|
-
return Number(result) === 1;
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
withLock(lock_identifier_1, callback_1) {
|
|
207
|
-
return __awaiter(this, arguments, void 0, function* (lock_identifier, callback, release_lock_delay_ms = 100) {
|
|
208
|
-
const lock_key = this.getLockKey(lock_identifier);
|
|
209
|
-
const lock_value = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
210
|
-
let retries = 0;
|
|
211
|
-
let acquired = false;
|
|
212
|
-
const firstTryTime = Date.now();
|
|
213
|
-
let getLockTime = 0;
|
|
214
|
-
try {
|
|
215
|
-
while (retries < this.lockMaxRetries) {
|
|
216
|
-
acquired = yield this.acquireLock(lock_key, lock_value);
|
|
217
|
-
if (acquired)
|
|
218
|
-
break;
|
|
219
|
-
yield new Promise(resolve => setTimeout(resolve, this.lockRetryDelayMs));
|
|
220
|
-
retries++;
|
|
221
|
-
}
|
|
222
|
-
if (acquired) {
|
|
223
|
-
getLockTime = Date.now();
|
|
224
|
-
return yield callback();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
finally {
|
|
228
|
-
if (acquired) {
|
|
229
|
-
const releaseDelay = parseInt(process.env.NONCE_LOCK_RELEASE_DELAY_MS || String(release_lock_delay_ms));
|
|
230
|
-
if (releaseDelay > 0) {
|
|
231
|
-
yield (0, index_1.sleep)(releaseDelay);
|
|
232
|
-
}
|
|
233
|
-
this.releaseLock(lock_key, lock_value);
|
|
234
|
-
(0, index_1.log_info)(`[Lock] withLock ok: key=${lock_key}, retries=${retries}, wait=${getLockTime - firstTryTime}ms, hold=${Date.now() - getLockTime}ms`);
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
(0, index_1.log_warn)(`[Lock] withLock failed: key=${lock_key}, retries=${retries}, took=${Date.now() - firstTryTime}ms`);
|
|
238
|
-
throw new Error(`get lock for ${lock_key} failed`);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
subscribe(channel, listener) {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
let reconnectCount = 0;
|
|
246
|
-
const doSubscribe = () => __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
try {
|
|
248
|
-
const subscriber = this.redis_client.duplicate();
|
|
249
|
-
subscriber.on('error', (err) => __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
(0, index_1.log_error)(`[PubSub] channel=${channel} error`, err);
|
|
251
|
-
if (reconnectCount >= MAX_SUBSCRIBE_RECONNECT) {
|
|
252
|
-
(0, index_1.log_warn)(`[PubSub] channel=${channel} exceeded max reconnect (${MAX_SUBSCRIBE_RECONNECT}), giving up`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
reconnectCount++;
|
|
256
|
-
const delay = Math.min(1000 * reconnectCount, 10000);
|
|
257
|
-
(0, index_1.log_info)(`[PubSub] channel=${channel} reconnect #${reconnectCount} in ${delay}ms`);
|
|
258
|
-
yield (0, index_1.sleep)(delay);
|
|
259
|
-
doSubscribe();
|
|
260
|
-
}));
|
|
261
|
-
yield subscriber.connect();
|
|
262
|
-
yield subscriber.subscribe(channel, listener);
|
|
263
|
-
reconnectCount = 0;
|
|
264
|
-
(0, index_1.log_info)(`[PubSub] subscribed to ${channel}`);
|
|
265
|
-
}
|
|
266
|
-
catch (err) {
|
|
267
|
-
(0, index_1.log_error)(`[PubSub] subscribe to ${channel} failed`, err);
|
|
268
|
-
if (reconnectCount < MAX_SUBSCRIBE_RECONNECT) {
|
|
269
|
-
reconnectCount++;
|
|
270
|
-
yield (0, index_1.sleep)(3000);
|
|
271
|
-
doSubscribe();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
yield doSubscribe();
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
publish(channel, message) {
|
|
279
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
280
|
-
this.redis_client.publish(channel, message);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
exports.RedisClient = RedisClient;
|
|
285
|
-
exports.RedisCommand = RedisClient;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getConfigCenterHttpOrigin(): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConfigCenterHttpOrigin = getConfigCenterHttpOrigin;
|
|
4
|
-
const service_ports_1 = require("../constants/service_ports");
|
|
5
|
-
function getConfigCenterHttpOrigin() {
|
|
6
|
-
const raw = (process.env.CONFIG_CENTER_HOST || '127.0.0.1').trim();
|
|
7
|
-
if (!raw) {
|
|
8
|
-
return `http://127.0.0.1:${service_ports_1.SERVICE_PORT.CONFIG_CENTER_HTTP}`;
|
|
9
|
-
}
|
|
10
|
-
if (/:\d+$/.test(raw) || /\]:\d+$/.test(raw)) {
|
|
11
|
-
return `http://${raw}`;
|
|
12
|
-
}
|
|
13
|
-
return `http://${raw}:${service_ports_1.SERVICE_PORT.CONFIG_CENTER_HTTP}`;
|
|
14
|
-
}
|