rocketmq-client-remoting-nodejs 0.0.0-stage → 0.0.1

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.
Files changed (137) hide show
  1. package/README.en.md +428 -0
  2. package/README.md +424 -2
  3. package/dist/client/admin.d.ts +229 -0
  4. package/dist/client/admin.js +2462 -0
  5. package/dist/client/allocate.d.ts +48 -0
  6. package/dist/client/allocate.js +365 -0
  7. package/dist/client/backpressure.d.ts +23 -0
  8. package/dist/client/backpressure.js +95 -0
  9. package/dist/client/consumer.d.ts +294 -0
  10. package/dist/client/consumer.js +3095 -0
  11. package/dist/client/consumer_result.d.ts +129 -0
  12. package/dist/client/consumer_result.js +138 -0
  13. package/dist/client/consumer_stats.d.ts +69 -0
  14. package/dist/client/consumer_stats.js +258 -0
  15. package/dist/client/exception.d.ts +39 -0
  16. package/dist/client/exception.js +36 -0
  17. package/dist/client/hook.d.ts +145 -0
  18. package/dist/client/hook.js +171 -0
  19. package/dist/client/latency.d.ts +61 -0
  20. package/dist/client/latency.js +239 -0
  21. package/dist/client/lite_pull_consumer.d.ts +151 -0
  22. package/dist/client/lite_pull_consumer.js +1096 -0
  23. package/dist/client/mq_client.d.ts +188 -0
  24. package/dist/client/mq_client.js +1678 -0
  25. package/dist/client/mq_client_manager.d.ts +21 -0
  26. package/dist/client/mq_client_manager.js +129 -0
  27. package/dist/client/offset_store.d.ts +45 -0
  28. package/dist/client/offset_store.js +389 -0
  29. package/dist/client/open_tracing_hook.d.ts +52 -0
  30. package/dist/client/open_tracing_hook.js +241 -0
  31. package/dist/client/pop_api.d.ts +28 -0
  32. package/dist/client/pop_api.js +224 -0
  33. package/dist/client/pop_consumer.d.ts +23 -0
  34. package/dist/client/pop_consumer.js +719 -0
  35. package/dist/client/pop_process_queue.d.ts +15 -0
  36. package/dist/client/pop_process_queue.js +51 -0
  37. package/dist/client/process_queue.d.ts +49 -0
  38. package/dist/client/process_queue.js +261 -0
  39. package/dist/client/produce_accumulator.d.ts +75 -0
  40. package/dist/client/produce_accumulator.js +288 -0
  41. package/dist/client/producer.d.ts +231 -0
  42. package/dist/client/producer.js +1774 -0
  43. package/dist/client/pull_api.d.ts +26 -0
  44. package/dist/client/pull_api.js +264 -0
  45. package/dist/client/pull_consumer.d.ts +119 -0
  46. package/dist/client/pull_consumer.js +876 -0
  47. package/dist/client/pull_schedule_service.d.ts +71 -0
  48. package/dist/client/pull_schedule_service.js +424 -0
  49. package/dist/client/request_reply.d.ts +61 -0
  50. package/dist/client/request_reply.js +232 -0
  51. package/dist/client/retry_message.d.ts +2 -0
  52. package/dist/client/retry_message.js +27 -0
  53. package/dist/client/send_result.d.ts +57 -0
  54. package/dist/client/send_result.js +70 -0
  55. package/dist/client/top_addressing.d.ts +20 -0
  56. package/dist/client/top_addressing.js +75 -0
  57. package/dist/client/trace_context.d.ts +61 -0
  58. package/dist/client/trace_context.js +373 -0
  59. package/dist/client/trace_dispatcher.d.ts +31 -0
  60. package/dist/client/trace_dispatcher.js +236 -0
  61. package/dist/client/trace_hook.d.ts +23 -0
  62. package/dist/client/trace_hook.js +228 -0
  63. package/dist/client/traceparent.d.ts +9 -0
  64. package/dist/client/traceparent.js +86 -0
  65. package/dist/common/boundary_type.d.ts +7 -0
  66. package/dist/common/boundary_type.js +16 -0
  67. package/dist/common/compress.d.ts +28 -0
  68. package/dist/common/compress.js +512 -0
  69. package/dist/common/message.d.ts +129 -0
  70. package/dist/common/message.js +214 -0
  71. package/dist/common/messageClientIdSetter.d.ts +7 -0
  72. package/dist/common/messageClientIdSetter.js +48 -0
  73. package/dist/common/messageConst.d.ts +68 -0
  74. package/dist/common/messageConst.js +68 -0
  75. package/dist/common/messageDecoder.d.ts +40 -0
  76. package/dist/common/messageDecoder.js +504 -0
  77. package/dist/common/messageType.d.ts +11 -0
  78. package/dist/common/messageType.js +11 -0
  79. package/dist/common/message_accessor.d.ts +39 -0
  80. package/dist/common/message_accessor.js +135 -0
  81. package/dist/common/mixAll.d.ts +106 -0
  82. package/dist/common/mixAll.js +247 -0
  83. package/dist/common/recall_message_handle.d.ts +25 -0
  84. package/dist/common/recall_message_handle.js +98 -0
  85. package/dist/common/subscriptionData.d.ts +36 -0
  86. package/dist/common/subscriptionData.js +64 -0
  87. package/dist/common/sysflag.d.ts +129 -0
  88. package/dist/common/sysflag.js +96 -0
  89. package/dist/common/topic_config.d.ts +66 -0
  90. package/dist/common/topic_config.js +106 -0
  91. package/dist/common/topic_validator.d.ts +49 -0
  92. package/dist/common/topic_validator.js +115 -0
  93. package/dist/common/utilAll.d.ts +39 -0
  94. package/dist/common/utilAll.js +154 -0
  95. package/dist/common/validators.d.ts +25 -0
  96. package/dist/common/validators.js +80 -0
  97. package/dist/index.d.ts +24 -0
  98. package/dist/index.js +36 -0
  99. package/dist/logging.d.ts +24 -0
  100. package/dist/logging.js +246 -0
  101. package/dist/remoting/acl.d.ts +16 -0
  102. package/dist/remoting/acl.js +39 -0
  103. package/dist/remoting/admin_body.d.ts +257 -0
  104. package/dist/remoting/admin_body.js +669 -0
  105. package/dist/remoting/bodies.d.ts +475 -0
  106. package/dist/remoting/bodies.js +1131 -0
  107. package/dist/remoting/client.d.ts +73 -0
  108. package/dist/remoting/client.js +591 -0
  109. package/dist/remoting/codes.d.ts +296 -0
  110. package/dist/remoting/codes.js +301 -0
  111. package/dist/remoting/exception.d.ts +45 -0
  112. package/dist/remoting/exception.js +58 -0
  113. package/dist/remoting/extra_info.d.ts +61 -0
  114. package/dist/remoting/extra_info.js +220 -0
  115. package/dist/remoting/headers.d.ts +758 -0
  116. package/dist/remoting/headers.js +1307 -0
  117. package/dist/remoting/heartbeat.d.ts +91 -0
  118. package/dist/remoting/heartbeat.js +227 -0
  119. package/dist/remoting/namespace.d.ts +14 -0
  120. package/dist/remoting/namespace.js +85 -0
  121. package/dist/remoting/pop_bodies.d.ts +58 -0
  122. package/dist/remoting/pop_bodies.js +214 -0
  123. package/dist/remoting/remotingCommand.d.ts +39 -0
  124. package/dist/remoting/remotingCommand.js +225 -0
  125. package/dist/remoting/route.d.ts +61 -0
  126. package/dist/remoting/route.js +288 -0
  127. package/dist/remoting/rpc_hooks.d.ts +31 -0
  128. package/dist/remoting/rpc_hooks.js +73 -0
  129. package/dist/remoting/serialize.d.ts +33 -0
  130. package/dist/remoting/serialize.js +372 -0
  131. package/dist/remoting/socks_proxy.d.ts +29 -0
  132. package/dist/remoting/socks_proxy.js +379 -0
  133. package/dist/remoting/static_topic.d.ts +49 -0
  134. package/dist/remoting/static_topic.js +244 -0
  135. package/dist/remoting/subscription.d.ts +65 -0
  136. package/dist/remoting/subscription.js +172 -0
  137. package/package.json +38 -4
@@ -0,0 +1,1131 @@
1
+ // -*- coding: utf-8 -*-
2
+ // Common request/response bodies for the classic remoting protocol.
3
+ // Many bodies contain Map<MessageQueue, X> whose JSON keys are inline object keys (the server's
4
+ // non-string-key JSON shape); we round-trip them with the fastjson-compatible RemotingSerializable.decode
5
+ // and the messageQueueKey helper. Field names match the wire protocol keys exactly.
6
+ import { MessageQueue } from "../common/message.js";
7
+ import { RemotingSerializable, decodeMessageQueueKey } from "./serialize.js";
8
+ import { BrokerData, QueueData, TopicRouteData, brokerData2Json, topicRouteData2TopicRouteDataJson } from "./route.js";
9
+ import { SubscriptionGroupWrapper } from "./subscription.js";
10
+ // Re-export route topic helpers so a single import surface covers bodies + route.
11
+ export { BrokerData, QueueData, TopicRouteData, brokerData2Json, topicRouteData2TopicRouteDataJson };
12
+ // Re-export subscription wrapper for callers that only import bodies.
13
+ export { SubscriptionGroupWrapper };
14
+ // ---------------------------------------------------------------------------
15
+ // MessageQueue <-> inline JSON key helper functions.
16
+ // ---------------------------------------------------------------------------
17
+ export function messageQueueKey(mq) {
18
+ return `{"brokerName":"${mq.brokerName}","queueId":${mq.queueId},"topic":"${mq.topic}"}`;
19
+ }
20
+ export function parseMessageQueueKey(key) {
21
+ const d = decodeMessageQueueKey(key);
22
+ if (d == null)
23
+ return null;
24
+ return new MessageQueue(d['topic'] != null ? d['topic'] : '', d['brokerName'] != null ? d['brokerName'] : '', d['queueId'] != null ? d['queueId'] : 0);
25
+ }
26
+ export function decodeMessageQueueMap(raw) {
27
+ const result = new Map();
28
+ const obj = raw || {};
29
+ for (const [k, v] of Object.entries(obj)) {
30
+ const mq = parseMessageQueueKey(k);
31
+ if (mq != null)
32
+ result.set(mq, v);
33
+ }
34
+ return result;
35
+ }
36
+ // ---------------------------------------------------------------------------
37
+ // Simple bodies
38
+ // ---------------------------------------------------------------------------
39
+ export class KVTable {
40
+ table;
41
+ constructor() { this.table = {}; }
42
+ toDict() { return { table: this.table }; }
43
+ static fromDict(d) {
44
+ const kv = new KVTable();
45
+ kv.table = Object.assign({}, d['table'] || {});
46
+ return kv;
47
+ }
48
+ encode() { return RemotingSerializable.encode(this.toDict()); }
49
+ static decode(data) { return KVTable.fromDict(RemotingSerializable.decode(data)); }
50
+ }
51
+ export class TopicList {
52
+ topicList;
53
+ brokerAddr;
54
+ constructor() { this.topicList = []; this.brokerAddr = null; }
55
+ toDict() {
56
+ const d = { topicList: this.topicList };
57
+ if (this.brokerAddr != null)
58
+ d['brokerAddr'] = this.brokerAddr;
59
+ return d;
60
+ }
61
+ static fromDict(d) {
62
+ const tl = new TopicList();
63
+ tl.topicList = (d['topicList'] || []).slice();
64
+ tl.brokerAddr = d['brokerAddr'] != null ? d['brokerAddr'] : null;
65
+ return tl;
66
+ }
67
+ encode() { return RemotingSerializable.encode(this.toDict()); }
68
+ static decode(data) { return TopicList.fromDict(RemotingSerializable.decode(data)); }
69
+ }
70
+ export class GroupList {
71
+ groupList;
72
+ constructor() { this.groupList = []; }
73
+ toDict() { return { groupList: this.groupList }; }
74
+ static fromDict(d) {
75
+ const gl = new GroupList();
76
+ gl.groupList = (d['groupList'] || []).slice();
77
+ return gl;
78
+ }
79
+ encode() { return RemotingSerializable.encode(this.toDict()); }
80
+ static decode(data) { return GroupList.fromDict(RemotingSerializable.decode(data)); }
81
+ }
82
+ export class LockBatchRequestBody {
83
+ consumerGroup;
84
+ clientId;
85
+ mqSet;
86
+ constructor() { this.consumerGroup = null; this.clientId = null; this.mqSet = []; }
87
+ toDict() {
88
+ return { consumerGroup: this.consumerGroup, clientId: this.clientId, mqSet: this.mqSet };
89
+ }
90
+ static fromDict(d) {
91
+ const b = new LockBatchRequestBody();
92
+ b.consumerGroup = d['consumerGroup'] != null ? d['consumerGroup'] : null;
93
+ b.clientId = d['clientId'] != null ? d['clientId'] : null;
94
+ b.mqSet = (d['mqSet'] || []).slice();
95
+ return b;
96
+ }
97
+ encode() { return RemotingSerializable.encode(this.toDict()); }
98
+ static decode(data) {
99
+ return LockBatchRequestBody.fromDict(RemotingSerializable.decode(data));
100
+ }
101
+ }
102
+ export class LockBatchResponseBody {
103
+ lockOKMQSet;
104
+ constructor() { this.lockOKMQSet = []; }
105
+ toDict() { return { lockOKMQSet: this.lockOKMQSet }; }
106
+ static fromDict(d) {
107
+ const b = new LockBatchResponseBody();
108
+ b.lockOKMQSet = (d['lockOKMQSet'] || []).slice();
109
+ return b;
110
+ }
111
+ encode() { return RemotingSerializable.encode(this.toDict()); }
112
+ static decode(data) {
113
+ return LockBatchResponseBody.fromDict(RemotingSerializable.decode(data));
114
+ }
115
+ }
116
+ export class UnlockBatchRequestBody {
117
+ consumerGroup;
118
+ clientId;
119
+ mqSet;
120
+ constructor() { this.consumerGroup = null; this.clientId = null; this.mqSet = []; }
121
+ toDict() {
122
+ return { consumerGroup: this.consumerGroup, clientId: this.clientId, mqSet: this.mqSet };
123
+ }
124
+ static fromDict(d) {
125
+ const b = new UnlockBatchRequestBody();
126
+ b.consumerGroup = d['consumerGroup'] != null ? d['consumerGroup'] : null;
127
+ b.clientId = d['clientId'] != null ? d['clientId'] : null;
128
+ b.mqSet = (d['mqSet'] || []).slice();
129
+ return b;
130
+ }
131
+ encode() { return RemotingSerializable.encode(this.toDict()); }
132
+ static decode(data) {
133
+ return UnlockBatchRequestBody.fromDict(RemotingSerializable.decode(data));
134
+ }
135
+ }
136
+ export class GetConsumerListByGroupResponseBody {
137
+ consumerIdList;
138
+ constructor() { this.consumerIdList = []; }
139
+ toDict() { return { consumerIdList: this.consumerIdList }; }
140
+ static fromDict(d) {
141
+ const b = new GetConsumerListByGroupResponseBody();
142
+ b.consumerIdList = (d['consumerIdList'] || []).slice();
143
+ return b;
144
+ }
145
+ encode() { return RemotingSerializable.encode(this.toDict()); }
146
+ static decode(data) {
147
+ return GetConsumerListByGroupResponseBody.fromDict(RemotingSerializable.decode(data));
148
+ }
149
+ }
150
+ export class CheckClientRequestBody {
151
+ clientId;
152
+ group;
153
+ subscriptionData;
154
+ namespace;
155
+ constructor() { this.clientId = null; this.group = null; this.subscriptionData = null; this.namespace = null; }
156
+ toDict() {
157
+ const d = { clientId: this.clientId, group: this.group };
158
+ if (this.subscriptionData != null)
159
+ d['subscriptionData'] = this.subscriptionData;
160
+ if (this.namespace != null)
161
+ d['namespace'] = this.namespace;
162
+ return d;
163
+ }
164
+ static fromDict(d) {
165
+ const b = new CheckClientRequestBody();
166
+ b.clientId = d['clientId'] != null ? d['clientId'] : null;
167
+ b.group = d['group'] != null ? d['group'] : null;
168
+ b.namespace = d['namespace'] != null ? d['namespace'] : null;
169
+ b.subscriptionData = d['subscriptionData'] != null ? d['subscriptionData'] : null;
170
+ return b;
171
+ }
172
+ encode() { return RemotingSerializable.encode(this.toDict()); }
173
+ static decode(data) {
174
+ return CheckClientRequestBody.fromDict(RemotingSerializable.decode(data));
175
+ }
176
+ }
177
+ export class ClusterInfo {
178
+ brokerAddrTable;
179
+ clusterAddrTable;
180
+ constructor() { this.brokerAddrTable = {}; this.clusterAddrTable = {}; }
181
+ getBrokerAddrs() {
182
+ const addrs = [];
183
+ const seen = new Set();
184
+ for (const name of Object.keys(this.brokerAddrTable).sort()) {
185
+ const inner = this.brokerAddrTable[name];
186
+ for (const id of Object.keys(inner).map((x) => parseInt(x, 10)).sort((a, b) => a - b)) {
187
+ const addr = inner[id];
188
+ if (addr && !seen.has(addr)) {
189
+ seen.add(addr);
190
+ addrs.push(addr);
191
+ }
192
+ }
193
+ }
194
+ return addrs;
195
+ }
196
+ toDict() {
197
+ const bat = {};
198
+ for (const [k, vv] of Object.entries(this.brokerAddrTable)) {
199
+ const addrs = {};
200
+ for (const [kk, v] of Object.entries(vv))
201
+ addrs[String(kk)] = v;
202
+ bat[k] = { cluster: '', brokerName: k, brokerAddrs: addrs, enableActingMaster: false };
203
+ }
204
+ return { brokerAddrTable: bat, clusterAddrTable: this.clusterAddrTable };
205
+ }
206
+ static fromDict(d) {
207
+ const ci = new ClusterInfo();
208
+ ci.brokerAddrTable = {};
209
+ for (const [k, vv] of Object.entries(d['brokerAddrTable'] || {})) {
210
+ const inner = vv['brokerAddrs'] || {};
211
+ const addrs = {};
212
+ for (const [kk, v] of Object.entries(inner))
213
+ addrs[parseInt(kk, 10)] = v;
214
+ ci.brokerAddrTable[k] = addrs;
215
+ }
216
+ ci.clusterAddrTable = Object.assign({}, d['clusterAddrTable'] || {});
217
+ return ci;
218
+ }
219
+ encode() { return RemotingSerializable.encode(this.toDict()); }
220
+ static decode(data) { return ClusterInfo.fromDict(RemotingSerializable.decode(data)); }
221
+ }
222
+ export class Connection {
223
+ clientId;
224
+ clientAddr;
225
+ language;
226
+ version;
227
+ constructor() { this.clientId = null; this.clientAddr = null; this.language = null; this.version = null; }
228
+ toDict() {
229
+ return { clientId: this.clientId, clientAddr: this.clientAddr, language: this.language, version: this.version };
230
+ }
231
+ static fromDict(d) {
232
+ const c = new Connection();
233
+ c.clientId = d['clientId'] != null ? d['clientId'] : null;
234
+ c.clientAddr = d['clientAddr'] != null ? d['clientAddr'] : null;
235
+ c.language = d['language'] != null ? d['language'] : null;
236
+ c.version = d['version'] != null ? d['version'] : null;
237
+ return c;
238
+ }
239
+ }
240
+ export class ConsumerConnection {
241
+ connectionSet;
242
+ subscriptionTable;
243
+ consumeType;
244
+ messageModel;
245
+ consumeFromWhere;
246
+ constructor() {
247
+ this.connectionSet = [];
248
+ this.subscriptionTable = {};
249
+ this.consumeType = null;
250
+ this.messageModel = null;
251
+ this.consumeFromWhere = null;
252
+ }
253
+ toDict() {
254
+ return {
255
+ connectionSet: this.connectionSet.map((c) => c.toDict()),
256
+ subscriptionTable: this.subscriptionTable,
257
+ consumeType: this.consumeType,
258
+ messageModel: this.messageModel,
259
+ consumeFromWhere: this.consumeFromWhere,
260
+ };
261
+ }
262
+ static fromDict(d) {
263
+ const cc = new ConsumerConnection();
264
+ cc.connectionSet = (d['connectionSet'] || []).map((c) => Connection.fromDict(c));
265
+ cc.subscriptionTable = Object.assign({}, d['subscriptionTable'] || {});
266
+ cc.consumeType = d['consumeType'] != null ? d['consumeType'] : null;
267
+ cc.messageModel = d['messageModel'] != null ? d['messageModel'] : null;
268
+ cc.consumeFromWhere = d['consumeFromWhere'] != null ? d['consumeFromWhere'] : null;
269
+ return cc;
270
+ }
271
+ encode() { return RemotingSerializable.encode(this.toDict()); }
272
+ static decode(data) {
273
+ return ConsumerConnection.fromDict(RemotingSerializable.decode(data));
274
+ }
275
+ }
276
+ export class ProducerConnection {
277
+ connectionSet;
278
+ constructor() { this.connectionSet = []; }
279
+ toDict() { return { connectionSet: this.connectionSet.map((c) => c.toDict()) }; }
280
+ static fromDict(d) {
281
+ const pc = new ProducerConnection();
282
+ pc.connectionSet = (d['connectionSet'] || []).map((c) => Connection.fromDict(c));
283
+ return pc;
284
+ }
285
+ encode() { return RemotingSerializable.encode(this.toDict()); }
286
+ static decode(data) {
287
+ return ProducerConnection.fromDict(RemotingSerializable.decode(data));
288
+ }
289
+ }
290
+ export class QueryConsumeTimeSpanBody {
291
+ consumeTimeSpanSet;
292
+ constructor() { this.consumeTimeSpanSet = []; }
293
+ toDict() { return { consumeTimeSpanSet: this.consumeTimeSpanSet }; }
294
+ static fromDict(d) {
295
+ const b = new QueryConsumeTimeSpanBody();
296
+ b.consumeTimeSpanSet = (d['consumeTimeSpanSet'] || []).slice();
297
+ return b;
298
+ }
299
+ encode() { return RemotingSerializable.encode(this.toDict()); }
300
+ static decode(data) {
301
+ return QueryConsumeTimeSpanBody.fromDict(RemotingSerializable.decode(data));
302
+ }
303
+ }
304
+ export class ConsumeStatus {
305
+ pullRT;
306
+ pullTPS;
307
+ consumeRT;
308
+ consumeOKTPS;
309
+ consumeFailedTPS;
310
+ consumeFailedMsgs;
311
+ constructor() {
312
+ this.pullRT = 0;
313
+ this.pullTPS = 0;
314
+ this.consumeRT = 0;
315
+ this.consumeOKTPS = 0;
316
+ this.consumeFailedTPS = 0;
317
+ this.consumeFailedMsgs = 0;
318
+ }
319
+ toDict() {
320
+ return {
321
+ pullRT: this.pullRT, pullTPS: this.pullTPS, consumeRT: this.consumeRT,
322
+ consumeOKTPS: this.consumeOKTPS, consumeFailedTPS: this.consumeFailedTPS,
323
+ consumeFailedMsgs: this.consumeFailedMsgs,
324
+ };
325
+ }
326
+ static fromDict(d) {
327
+ const cs = new ConsumeStatus();
328
+ cs.pullRT = d['pullRT'] != null ? d['pullRT'] : 0;
329
+ cs.pullTPS = d['pullTPS'] != null ? d['pullTPS'] : 0;
330
+ cs.consumeRT = d['consumeRT'] != null ? d['consumeRT'] : 0;
331
+ cs.consumeOKTPS = d['consumeOKTPS'] != null ? d['consumeOKTPS'] : 0;
332
+ cs.consumeFailedTPS = d['consumeFailedTPS'] != null ? d['consumeFailedTPS'] : 0;
333
+ cs.consumeFailedMsgs = d['consumeFailedMsgs'] != null ? d['consumeFailedMsgs'] : 0;
334
+ return cs;
335
+ }
336
+ }
337
+ export class ConsumeStatsList {
338
+ statsList;
339
+ brokerAddr;
340
+ totalDiff;
341
+ totalInflightDiff;
342
+ constructor() { this.statsList = []; this.brokerAddr = null; this.totalDiff = 0; this.totalInflightDiff = 0; }
343
+ toDict() {
344
+ const d = { consumeStatsList: this.statsList };
345
+ if (this.brokerAddr != null)
346
+ d['brokerAddr'] = this.brokerAddr;
347
+ d['totalDiff'] = this.totalDiff;
348
+ d['totalInflightDiff'] = this.totalInflightDiff;
349
+ return d;
350
+ }
351
+ static fromDict(d) {
352
+ const sl = new ConsumeStatsList();
353
+ sl.statsList = (d['consumeStatsList'] || []).slice();
354
+ sl.brokerAddr = d['brokerAddr'] != null ? d['brokerAddr'] : null;
355
+ sl.totalDiff = parseInt(d['totalDiff'] != null ? d['totalDiff'] : 0, 10);
356
+ sl.totalInflightDiff = parseInt(d['totalInflightDiff'] != null ? d['totalInflightDiff'] : 0, 10);
357
+ return sl;
358
+ }
359
+ encode() { return RemotingSerializable.encode(this.toDict()); }
360
+ static decode(data) {
361
+ return ConsumeStatsList.fromDict(RemotingSerializable.decode(data));
362
+ }
363
+ }
364
+ export class ResetOffsetBody {
365
+ offsetTable;
366
+ constructor() { this.offsetTable = new Map(); }
367
+ toDict() {
368
+ const t = {};
369
+ for (const [mq, v] of this.offsetTable)
370
+ t[messageQueueKey(mq)] = v;
371
+ return { offsetTable: t };
372
+ }
373
+ static fromDict(d) {
374
+ const b = new ResetOffsetBody();
375
+ const m = decodeMessageQueueMap(d['offsetTable']);
376
+ for (const [mq, v] of m)
377
+ b.offsetTable.set(mq, parseInt(v, 10));
378
+ return b;
379
+ }
380
+ encode() { return RemotingSerializable.encode(this.toDict()); }
381
+ static decode(data) {
382
+ return ResetOffsetBody.fromDict(RemotingSerializable.decode(data));
383
+ }
384
+ }
385
+ export class MessageQueueForC {
386
+ topic;
387
+ brokerName;
388
+ queueId;
389
+ offset;
390
+ constructor(topic = '', brokerName = '', queueId = 0, offset = 0) {
391
+ this.topic = topic;
392
+ this.brokerName = brokerName;
393
+ this.queueId = queueId;
394
+ this.offset = offset;
395
+ }
396
+ toDict() {
397
+ return { topic: this.topic, brokerName: this.brokerName, queueId: this.queueId, offset: this.offset };
398
+ }
399
+ static fromDict(d) {
400
+ return new MessageQueueForC(d['topic'] != null ? d['topic'] : '', d['brokerName'] != null ? d['brokerName'] : '', parseInt(d['queueId'] != null ? d['queueId'] : 0, 10), parseInt(d['offset'] != null ? d['offset'] : 0, 10));
401
+ }
402
+ }
403
+ export class ResetOffsetBodyForC {
404
+ offsetTable;
405
+ constructor() { this.offsetTable = []; }
406
+ toDict() { return { offsetTable: this.offsetTable.map((e) => e.toDict()) }; }
407
+ static fromDict(d) {
408
+ const b = new ResetOffsetBodyForC();
409
+ for (const item of (d['offsetTable'] || [])) {
410
+ if (item && typeof item === 'object')
411
+ b.offsetTable.push(MessageQueueForC.fromDict(item));
412
+ }
413
+ return b;
414
+ }
415
+ encode() { return RemotingSerializable.encode(this.toDict()); }
416
+ static decode(data) {
417
+ return ResetOffsetBodyForC.fromDict(RemotingSerializable.decode(data));
418
+ }
419
+ }
420
+ export class GetConsumerStatusBody {
421
+ messageQueueTable;
422
+ consumerTable;
423
+ constructor() { this.messageQueueTable = new Map(); this.consumerTable = {}; }
424
+ toDict() {
425
+ const mqt = {};
426
+ for (const [mq, v] of this.messageQueueTable)
427
+ mqt[messageQueueKey(mq)] = v;
428
+ const ct = {};
429
+ for (const [cid, tbl] of Object.entries(this.consumerTable)) {
430
+ const t = {};
431
+ for (const [mq, v] of tbl)
432
+ t[messageQueueKey(mq)] = v;
433
+ ct[cid] = t;
434
+ }
435
+ return { messageQueueTable: mqt, consumerTable: ct };
436
+ }
437
+ static fromDict(d) {
438
+ const b = new GetConsumerStatusBody();
439
+ const m = decodeMessageQueueMap(d['messageQueueTable']);
440
+ for (const [mq, v] of m)
441
+ b.messageQueueTable.set(mq, parseInt(v, 10));
442
+ for (const [cid, tbl] of Object.entries(d['consumerTable'] || {})) {
443
+ const inner = new Map();
444
+ const m2 = decodeMessageQueueMap(tbl);
445
+ for (const [mq, v] of m2)
446
+ inner.set(mq, parseInt(v, 10));
447
+ b.consumerTable[cid] = inner;
448
+ }
449
+ return b;
450
+ }
451
+ encode() { return RemotingSerializable.encode(this.toDict()); }
452
+ static decode(data) {
453
+ return GetConsumerStatusBody.fromDict(RemotingSerializable.decode(data));
454
+ }
455
+ }
456
+ export class ProcessQueueInfo {
457
+ commitOffset;
458
+ cachedMsgMinOffset;
459
+ cachedMsgMaxOffset;
460
+ cachedMsgCount;
461
+ cachedMsgSizeInMiB;
462
+ transactionMsgMinOffset;
463
+ transactionMsgMaxOffset;
464
+ transactionMsgCount;
465
+ locked;
466
+ tryUnlockTimes;
467
+ lastLockTimestamp;
468
+ droped;
469
+ lastPullTimestamp;
470
+ lastConsumeTimestamp;
471
+ constructor() {
472
+ this.commitOffset = 0;
473
+ this.cachedMsgMinOffset = 0;
474
+ this.cachedMsgMaxOffset = 0;
475
+ this.cachedMsgCount = 0;
476
+ this.cachedMsgSizeInMiB = 0;
477
+ this.transactionMsgMinOffset = 0;
478
+ this.transactionMsgMaxOffset = 0;
479
+ this.transactionMsgCount = 0;
480
+ this.locked = false;
481
+ this.tryUnlockTimes = 0;
482
+ this.lastLockTimestamp = 0;
483
+ this.droped = false;
484
+ this.lastPullTimestamp = 0;
485
+ this.lastConsumeTimestamp = 0;
486
+ }
487
+ toDict() {
488
+ return {
489
+ commitOffset: this.commitOffset, cachedMsgMinOffset: this.cachedMsgMinOffset,
490
+ cachedMsgMaxOffset: this.cachedMsgMaxOffset, cachedMsgCount: this.cachedMsgCount,
491
+ cachedMsgSizeInMiB: this.cachedMsgSizeInMiB, transactionMsgMinOffset: this.transactionMsgMinOffset,
492
+ transactionMsgMaxOffset: this.transactionMsgMaxOffset, transactionMsgCount: this.transactionMsgCount,
493
+ locked: this.locked, tryUnlockTimes: this.tryUnlockTimes, lastLockTimestamp: this.lastLockTimestamp,
494
+ droped: this.droped, lastPullTimestamp: this.lastPullTimestamp, lastConsumeTimestamp: this.lastConsumeTimestamp,
495
+ };
496
+ }
497
+ static fromDict(d) {
498
+ const p = new ProcessQueueInfo();
499
+ p.commitOffset = parseInt(d['commitOffset'] != null ? d['commitOffset'] : 0, 10);
500
+ p.cachedMsgMinOffset = parseInt(d['cachedMsgMinOffset'] != null ? d['cachedMsgMinOffset'] : 0, 10);
501
+ p.cachedMsgMaxOffset = parseInt(d['cachedMsgMaxOffset'] != null ? d['cachedMsgMaxOffset'] : 0, 10);
502
+ p.cachedMsgCount = parseInt(d['cachedMsgCount'] != null ? d['cachedMsgCount'] : 0, 10);
503
+ p.cachedMsgSizeInMiB = parseInt(d['cachedMsgSizeInMiB'] != null ? d['cachedMsgSizeInMiB'] : 0, 10);
504
+ p.transactionMsgMinOffset = parseInt(d['transactionMsgMinOffset'] != null ? d['transactionMsgMinOffset'] : 0, 10);
505
+ p.transactionMsgMaxOffset = parseInt(d['transactionMsgMaxOffset'] != null ? d['transactionMsgMaxOffset'] : 0, 10);
506
+ p.transactionMsgCount = parseInt(d['transactionMsgCount'] != null ? d['transactionMsgCount'] : 0, 10);
507
+ p.locked = d['locked'] === true;
508
+ p.tryUnlockTimes = parseInt(d['tryUnlockTimes'] != null ? d['tryUnlockTimes'] : 0, 10);
509
+ p.lastLockTimestamp = parseInt(d['lastLockTimestamp'] != null ? d['lastLockTimestamp'] : 0, 10);
510
+ p.droped = d['droped'] === true;
511
+ p.lastPullTimestamp = parseInt(d['lastPullTimestamp'] != null ? d['lastPullTimestamp'] : 0, 10);
512
+ p.lastConsumeTimestamp = parseInt(d['lastConsumeTimestamp'] != null ? d['lastConsumeTimestamp'] : 0, 10);
513
+ return p;
514
+ }
515
+ }
516
+ export class CMResult {
517
+ static CR_SUCCESS = 'CR_SUCCESS';
518
+ static CR_LATER = 'CR_LATER';
519
+ static CR_ROLLBACK = 'CR_ROLLBACK';
520
+ static CR_COMMIT = 'CR_COMMIT';
521
+ static CR_THROW_EXCEPTION = 'CR_THROW_EXCEPTION';
522
+ static CR_RETURN_NULL = 'CR_RETURN_NULL';
523
+ }
524
+ export class ConsumeMessageDirectlyResult {
525
+ order;
526
+ autoCommit;
527
+ consumeResult;
528
+ remark;
529
+ spentTimeMills;
530
+ constructor() {
531
+ this.order = false;
532
+ this.autoCommit = true;
533
+ this.consumeResult = null;
534
+ this.remark = null;
535
+ this.spentTimeMills = 0;
536
+ }
537
+ toDict() {
538
+ return {
539
+ order: this.order, autoCommit: this.autoCommit, consumeResult: this.consumeResult,
540
+ remark: this.remark, spentTimeMills: this.spentTimeMills,
541
+ };
542
+ }
543
+ static fromDict(d) {
544
+ const r = new ConsumeMessageDirectlyResult();
545
+ r.order = d['order'] === true;
546
+ r.autoCommit = d['autoCommit'] !== false;
547
+ r.consumeResult = d['consumeResult'] != null ? d['consumeResult'] : null;
548
+ r.remark = d['remark'] != null ? d['remark'] : null;
549
+ r.spentTimeMills = parseInt(d['spentTimeMills'] != null ? d['spentTimeMills'] : 0, 10);
550
+ return r;
551
+ }
552
+ encode() { return RemotingSerializable.encode(this.toDict()); }
553
+ static decode(data) {
554
+ return ConsumeMessageDirectlyResult.fromDict(RemotingSerializable.decode(data));
555
+ }
556
+ }
557
+ // ---------------------------------------------------------------------------
558
+ // ConsumerRunningInfo (307 response). Properties + subscriptionSet + mqTable +
559
+ // mqPopTable + statusTable + userConsumerInfo + jstack.
560
+ // ---------------------------------------------------------------------------
561
+ export class ConsumerRunningInfo {
562
+ static PROP_NAMESERVER_ADDR = 'PROP_NAMESERVER_ADDR';
563
+ static PROP_THREADPOOL_CORE_SIZE = 'PROP_THREADPOOL_CORE_SIZE';
564
+ static PROP_CONSUME_ORDERLY = 'PROP_CONSUMEORDERLY';
565
+ static PROP_CONSUME_TYPE = 'PROP_CONSUME_TYPE';
566
+ static PROP_CLIENT_VERSION = 'PROP_CLIENT_VERSION';
567
+ static PROP_CONSUMER_START_TIMESTAMP = 'PROP_CONSUMER_START_TIMESTAMP';
568
+ properties;
569
+ subscriptionSet;
570
+ mqTable;
571
+ mqPopTable;
572
+ statusTable;
573
+ userConsumerInfo;
574
+ jstack;
575
+ constructor() {
576
+ this.properties = {};
577
+ this.subscriptionSet = [];
578
+ this.mqTable = new Map();
579
+ this.mqPopTable = new Map();
580
+ this.statusTable = {};
581
+ this.userConsumerInfo = {};
582
+ this.jstack = null;
583
+ }
584
+ toDict() {
585
+ const mqt = {};
586
+ for (const [mq, v] of this.mqTable)
587
+ mqt[messageQueueKey(mq)] = v;
588
+ const mpt = {};
589
+ for (const [mq, v] of this.mqPopTable)
590
+ mpt[messageQueueKey(mq)] = v;
591
+ return {
592
+ properties: this.properties,
593
+ subscriptionSet: this.subscriptionSet,
594
+ mqTable: mqt,
595
+ mqPopTable: mpt,
596
+ statusTable: this.statusTable,
597
+ userConsumerInfo: this.userConsumerInfo,
598
+ jstack: this.jstack,
599
+ };
600
+ }
601
+ static fromDict(d) {
602
+ const ri = new ConsumerRunningInfo();
603
+ ri.properties = Object.assign({}, d['properties'] || {});
604
+ ri.subscriptionSet = (d['subscriptionSet'] || []).slice();
605
+ const mqtMap = decodeMessageQueueMap(d['mqTable']);
606
+ for (const [mq, v] of mqtMap)
607
+ ri.mqTable.set(mq, v);
608
+ const mptMap = decodeMessageQueueMap(d['mqPopTable']);
609
+ for (const [mq, v] of mptMap)
610
+ ri.mqPopTable.set(mq, v);
611
+ ri.statusTable = Object.assign({}, d['statusTable'] || {});
612
+ ri.userConsumerInfo = Object.assign({}, d['userConsumerInfo'] || {});
613
+ ri.jstack = d['jstack'] != null ? d['jstack'] : null;
614
+ return ri;
615
+ }
616
+ encode() { return RemotingSerializable.encode(this.toDict()); }
617
+ static decode(data) {
618
+ return ConsumerRunningInfo.fromDict(RemotingSerializable.decode(data));
619
+ }
620
+ // Build a tps summary from statusTable, given a sampler that injects the two
621
+ // timestamps (pull/consume) needed to compute throughput. `manager` is the
622
+ // consumption status manager that exposes pullTps/consumeTps, etc.
623
+ computeTps(manager) {
624
+ if (!manager || !manager.getTps)
625
+ return 0;
626
+ let total = 0;
627
+ for (const mq of this.mqTable.keys())
628
+ total += manager.getTps(mq, Date.now());
629
+ return total;
630
+ }
631
+ }
632
+ // ---------------------------------------------------------------------------
633
+ // TopicConfig (shared by bodies and admin). Defaults: readQueueNums=16,
634
+ // writeQueueNums=16, perm=6, topicFilterType=SINGLE_TAG, topicSysFlag=0,
635
+ // order=false, attributes={}.
636
+ // ---------------------------------------------------------------------------
637
+ export const TopicFilterType = {
638
+ SINGLE_TAG: 'SINGLE_TAG',
639
+ MULTI_TAG: 'MULTI_TAG',
640
+ };
641
+ export const DEFAULT_READ_QUEUE_NUMS = 16;
642
+ export const DEFAULT_WRITE_QUEUE_NUMS = 16;
643
+ export const DEFAULT_PERM = 6;
644
+ export class TopicConfig {
645
+ topicName;
646
+ readQueueNums;
647
+ writeQueueNums;
648
+ perm;
649
+ topicFilterType;
650
+ topicSysFlag;
651
+ order;
652
+ attributes;
653
+ constructor(topicName = '', readQueueNums = DEFAULT_READ_QUEUE_NUMS, writeQueueNums = DEFAULT_WRITE_QUEUE_NUMS, perm = DEFAULT_PERM, topicFilterType = TopicFilterType.SINGLE_TAG, topicSysFlag = 0, order = false) {
654
+ this.topicName = topicName;
655
+ this.readQueueNums = readQueueNums;
656
+ this.writeQueueNums = writeQueueNums;
657
+ this.perm = perm;
658
+ this.topicFilterType = topicFilterType;
659
+ this.topicSysFlag = topicSysFlag;
660
+ this.order = order;
661
+ this.attributes = {};
662
+ }
663
+ toDict() {
664
+ return {
665
+ topicName: this.topicName,
666
+ readQueueNums: this.readQueueNums,
667
+ writeQueueNums: this.writeQueueNums,
668
+ perm: this.perm,
669
+ topicFilterType: this.topicFilterType,
670
+ topicSysFlag: this.topicSysFlag,
671
+ order: this.order,
672
+ attributes: this.attributes,
673
+ };
674
+ }
675
+ static fromDict(d) {
676
+ return new TopicConfig(d['topicName'] != null ? d['topicName'] : '', parseInt(d['readQueueNums'] != null ? d['readQueueNums'] : DEFAULT_READ_QUEUE_NUMS, 10), parseInt(d['writeQueueNums'] != null ? d['writeQueueNums'] : DEFAULT_WRITE_QUEUE_NUMS, 10), parseInt(d['perm'] != null ? d['perm'] : DEFAULT_PERM, 10), d['topicFilterType'] != null ? d['topicFilterType'] : TopicFilterType.SINGLE_TAG, parseInt(d['topicSysFlag'] != null ? d['topicSysFlag'] : 0, 10), d['order'] === true);
677
+ }
678
+ // Note: the UPDATE_AND_CREATE_TOPIC body also has a private binary KV codec on the server side
679
+ // (TopicConfig readBody/writeBody) which is outside the general-purpose RocketMQSerializable
680
+ // serialization scope; we do not implement that codec here and keep encode/decode on JSON, consistent
681
+ // with the other bodies.
682
+ encode() { return RemotingSerializable.encode(this.toDict()); }
683
+ static decode(data) {
684
+ return TopicConfig.fromDict(RemotingSerializable.decode(data));
685
+ }
686
+ }
687
+ export class TopicConfigSerializeWrapper {
688
+ topicConfigTable;
689
+ dataVersion;
690
+ constructor() { this.topicConfigTable = {}; this.dataVersion = {}; }
691
+ toDict() {
692
+ const table = {};
693
+ for (const [k, v] of Object.entries(this.topicConfigTable))
694
+ table[k] = v.toDict();
695
+ return { dataVersion: this.dataVersion, topicConfigTable: table };
696
+ }
697
+ static fromDict(d) {
698
+ const w = new TopicConfigSerializeWrapper();
699
+ const table = d['topicConfigTable'] || {};
700
+ for (const [k, v] of Object.entries(table))
701
+ w.topicConfigTable[k] = TopicConfig.fromDict(v);
702
+ w.dataVersion = Object.assign({}, d['dataVersion'] || {});
703
+ return w;
704
+ }
705
+ encode() { return RemotingSerializable.encode(this.toDict()); }
706
+ static decode(data) {
707
+ return TopicConfigSerializeWrapper.fromDict(RemotingSerializable.decode(data));
708
+ }
709
+ }
710
+ // ---------------------------------------------------------------------------
711
+ // ConsumeStats + OffsetWrapper (admin; shared with admin_body via re-export).
712
+ // ---------------------------------------------------------------------------
713
+ export class OffsetWrapper {
714
+ brokerOffset;
715
+ consumerOffset;
716
+ lastTimestamp;
717
+ pullOffset;
718
+ constructor(brokerOffset = 0, consumerOffset = 0, lastTimestamp = 0, pullOffset = 0) {
719
+ this.brokerOffset = brokerOffset;
720
+ this.consumerOffset = consumerOffset;
721
+ this.lastTimestamp = lastTimestamp;
722
+ this.pullOffset = pullOffset;
723
+ }
724
+ get lag() { return this.brokerOffset - this.consumerOffset; }
725
+ toDict() {
726
+ return {
727
+ brokerOffset: this.brokerOffset, consumerOffset: this.consumerOffset,
728
+ lastTimestamp: this.lastTimestamp, pullOffset: this.pullOffset,
729
+ };
730
+ }
731
+ static fromDict(d) {
732
+ return new OffsetWrapper(parseInt(d['brokerOffset'] != null ? d['brokerOffset'] : 0, 10), parseInt(d['consumerOffset'] != null ? d['consumerOffset'] : 0, 10), parseInt(d['lastTimestamp'] != null ? d['lastTimestamp'] : 0, 10), parseInt(d['pullOffset'] != null ? d['pullOffset'] : 0, 10));
733
+ }
734
+ }
735
+ export class ConsumeStats {
736
+ offsetTable;
737
+ consumeTps;
738
+ constructor() { this.offsetTable = new Map(); this.consumeTps = 0; }
739
+ get totalLag() {
740
+ let s = 0;
741
+ for (const ow of this.offsetTable.values())
742
+ s += ow.lag;
743
+ return s;
744
+ }
745
+ toDict() {
746
+ const t = {};
747
+ for (const [mq, v] of this.offsetTable)
748
+ t[messageQueueKey(mq)] = v.toDict();
749
+ return { offsetTable: t, consumeTps: this.consumeTps };
750
+ }
751
+ static fromDict(d) {
752
+ const cs = new ConsumeStats();
753
+ const m = decodeMessageQueueMap(d['offsetTable']);
754
+ for (const [mq, v] of m)
755
+ cs.offsetTable.set(mq, OffsetWrapper.fromDict(v));
756
+ cs.consumeTps = d['consumeTps'] != null ? d['consumeTps'] : 0;
757
+ return cs;
758
+ }
759
+ encode() { return RemotingSerializable.encode(this.toDict()); }
760
+ static decode(data) {
761
+ return ConsumeStats.fromDict(RemotingSerializable.decode(data));
762
+ }
763
+ }
764
+ // ---------------------------------------------------------------------------
765
+ // BrokerStatsData + StatsItem (VIEW_BROKER_STATS_DATA).
766
+ // ---------------------------------------------------------------------------
767
+ export class StatsItem {
768
+ statsName;
769
+ statsKey;
770
+ sum;
771
+ tps;
772
+ times;
773
+ value;
774
+ constructor() { this.statsName = ''; this.statsKey = ''; this.sum = 0; this.tps = 0; this.times = 0; this.value = 0; }
775
+ toDict() {
776
+ return { statsName: this.statsName, statsKey: this.statsKey, sum: this.sum, tps: this.tps, times: this.times, value: this.value };
777
+ }
778
+ static fromDict(d) {
779
+ const s = new StatsItem();
780
+ s.statsName = d['statsName'] != null ? d['statsName'] : '';
781
+ s.statsKey = d['statsKey'] != null ? d['statsKey'] : '';
782
+ s.sum = d['sum'] != null ? d['sum'] : 0;
783
+ s.tps = d['tps'] != null ? d['tps'] : 0;
784
+ s.times = d['times'] != null ? d['times'] : 0;
785
+ s.value = d['value'] != null ? d['value'] : 0;
786
+ return s;
787
+ }
788
+ }
789
+ export class BrokerStatsData {
790
+ brokerPutNums;
791
+ brokerGetNums;
792
+ brokerGetSize;
793
+ brokerSucPutTimes;
794
+ brokerSucGetTimes;
795
+ msgPutTotalYesterdayMorning;
796
+ msgPutTotalTodayMorning;
797
+ msgGetTotalYesterdayMorning;
798
+ msgGetTotalTodayMorning;
799
+ msgPutTotalTodayNow;
800
+ msgGetTotalTodayNow;
801
+ putTps;
802
+ getTps;
803
+ getTransferredTps;
804
+ constructor() {
805
+ this.brokerPutNums = new StatsItem();
806
+ this.brokerGetNums = new StatsItem();
807
+ this.brokerGetSize = new StatsItem();
808
+ this.brokerSucPutTimes = new StatsItem();
809
+ this.brokerSucGetTimes = new StatsItem();
810
+ this.msgPutTotalYesterdayMorning = 0;
811
+ this.msgPutTotalTodayMorning = 0;
812
+ this.msgGetTotalYesterdayMorning = 0;
813
+ this.msgGetTotalTodayMorning = 0;
814
+ this.msgPutTotalTodayNow = 0;
815
+ this.msgGetTotalTodayNow = 0;
816
+ this.putTps = [];
817
+ this.getTps = [];
818
+ this.getTransferredTps = [];
819
+ }
820
+ toDict() {
821
+ return {
822
+ brokerPutNums: this.brokerPutNums.toDict(), brokerGetNums: this.brokerGetNums.toDict(),
823
+ brokerGetSize: this.brokerGetSize.toDict(), brokerSucPutTimes: this.brokerSucPutTimes.toDict(),
824
+ brokerSucGetTimes: this.brokerSucGetTimes.toDict(),
825
+ msgPutTotalYesterdayMorning: this.msgPutTotalYesterdayMorning,
826
+ msgPutTotalTodayMorning: this.msgPutTotalTodayMorning,
827
+ msgGetTotalYesterdayMorning: this.msgGetTotalYesterdayMorning,
828
+ msgGetTotalTodayMorning: this.msgGetTotalTodayMorning,
829
+ msgPutTotalTodayNow: this.msgPutTotalTodayNow, msgGetTotalTodayNow: this.msgGetTotalTodayNow,
830
+ putTps: this.putTps, getTps: this.getTps, getTransferredTps: this.getTransferredTps,
831
+ };
832
+ }
833
+ static fromDict(d) {
834
+ const b = new BrokerStatsData();
835
+ b.brokerPutNums = StatsItem.fromDict(d['brokerPutNums'] || {});
836
+ b.brokerGetNums = StatsItem.fromDict(d['brokerGetNums'] || {});
837
+ b.brokerGetSize = StatsItem.fromDict(d['brokerGetSize'] || {});
838
+ b.brokerSucPutTimes = StatsItem.fromDict(d['brokerSucPutTimes'] || {});
839
+ b.brokerSucGetTimes = StatsItem.fromDict(d['brokerSucGetTimes'] || {});
840
+ b.msgPutTotalYesterdayMorning = parseInt(d['msgPutTotalYesterdayMorning'] != null ? d['msgPutTotalYesterdayMorning'] : 0, 10);
841
+ b.msgPutTotalTodayMorning = parseInt(d['msgPutTotalTodayMorning'] != null ? d['msgPutTotalTodayMorning'] : 0, 10);
842
+ b.msgGetTotalYesterdayMorning = parseInt(d['msgGetTotalYesterdayMorning'] != null ? d['msgGetTotalYesterdayMorning'] : 0, 10);
843
+ b.msgGetTotalTodayMorning = parseInt(d['msgGetTotalTodayMorning'] != null ? d['msgGetTotalTodayMorning'] : 0, 10);
844
+ b.msgPutTotalTodayNow = parseInt(d['msgPutTotalTodayNow'] != null ? d['msgPutTotalTodayNow'] : 0, 10);
845
+ b.msgGetTotalTodayNow = parseInt(d['msgGetTotalTodayNow'] != null ? d['msgGetTotalTodayNow'] : 0, 10);
846
+ b.putTps = (d['putTps'] || []).map((x) => Number(x));
847
+ b.getTps = (d['getTps'] || []).map((x) => Number(x));
848
+ b.getTransferredTps = (d['getTransferredTps'] || []).map((x) => Number(x));
849
+ return b;
850
+ }
851
+ encode() { return RemotingSerializable.encode(this.toDict()); }
852
+ static decode(data) {
853
+ return BrokerStatsData.fromDict(RemotingSerializable.decode(data));
854
+ }
855
+ }
856
+ // MessageRequestMode (SET_MESSAGE_REQUEST_MODE enum: PULL=0, POP=1).
857
+ export const MessageRequestMode = {
858
+ PULL: 0,
859
+ POP: 1,
860
+ };
861
+ // ---------------------------------------------------------------------------
862
+ // QueryMsgResponseBody (QUERY_MESSAGE response).
863
+ // ---------------------------------------------------------------------------
864
+ export class QueryMsgResponseBody {
865
+ indexLastUpdateTimestamp;
866
+ msgIdSet;
867
+ msgIdList;
868
+ constructor() { this.indexLastUpdateTimestamp = 0; this.msgIdSet = []; this.msgIdList = []; }
869
+ toDict() {
870
+ return {
871
+ indexLastUpdateTimestamp: this.indexLastUpdateTimestamp,
872
+ msgIdSet: this.msgIdSet, msgIdList: this.msgIdList,
873
+ };
874
+ }
875
+ static fromDict(d) {
876
+ const b = new QueryMsgResponseBody();
877
+ b.indexLastUpdateTimestamp = parseInt(d['indexLastUpdateTimestamp'] != null ? d['indexLastUpdateTimestamp'] : 0, 10);
878
+ b.msgIdSet = (d['msgIdSet'] || d['msgIdList'] || []).slice();
879
+ b.msgIdList = (d['msgIdList'] || d['msgIdSet'] || []).slice();
880
+ return b;
881
+ }
882
+ encode() { return RemotingSerializable.encode(this.toDict()); }
883
+ static decode(data) {
884
+ return QueryMsgResponseBody.fromDict(RemotingSerializable.decode(data));
885
+ }
886
+ }
887
+ // QueryResult (optional, lightweight): holds the index timestamp + raw messages.
888
+ export class QueryResult {
889
+ indexLastUpdateTimestamp;
890
+ messageList;
891
+ constructor() { this.indexLastUpdateTimestamp = 0; this.messageList = []; }
892
+ toDict() {
893
+ return { indexLastUpdateTimestamp: this.indexLastUpdateTimestamp, messageList: this.messageList };
894
+ }
895
+ static fromDict(d) {
896
+ const q = new QueryResult();
897
+ q.indexLastUpdateTimestamp = parseInt(d['indexLastUpdateTimestamp'] != null ? d['indexLastUpdateTimestamp'] : 0, 10);
898
+ q.messageList = (d['messageList'] || []).slice();
899
+ return q;
900
+ }
901
+ }
902
+ // ---------------------------------------------------------------------------
903
+ // #47 mqadmin ops RPC bodies (Java remoting.protocol.body.*)
904
+ // ---------------------------------------------------------------------------
905
+ // QUERY_CORRECTION_OFFSET(308). JSON object keys are strings; Java holds
906
+ // Map<Integer, Long>, so the keys are parsed back to numbers.
907
+ export class QueryCorrectionOffsetBody {
908
+ correctionOffsets = {};
909
+ static fromDict(d) {
910
+ const b = new QueryCorrectionOffsetBody();
911
+ const raw = d['correctionOffsets'] || {};
912
+ for (const k of Object.keys(raw))
913
+ b.correctionOffsets[parseInt(k, 10)] = parseInt(raw[k], 10);
914
+ return b;
915
+ }
916
+ static decode(data) {
917
+ return QueryCorrectionOffsetBody.fromDict(RemotingSerializable.decode(data));
918
+ }
919
+ }
920
+ // One entry of ProducerTableInfo.data (GET_ALL_PRODUCER_INFO = 328).
921
+ export class ProducerInfo {
922
+ clientId;
923
+ remoteIP;
924
+ language;
925
+ version;
926
+ lastUpdateTimestamp;
927
+ constructor() {
928
+ this.clientId = null;
929
+ this.remoteIP = null;
930
+ this.language = null;
931
+ this.version = 0;
932
+ this.lastUpdateTimestamp = 0;
933
+ }
934
+ static fromDict(d) {
935
+ const p = new ProducerInfo();
936
+ p.clientId = d['clientId'] != null ? d['clientId'] : null;
937
+ p.remoteIP = d['remoteIP'] != null ? d['remoteIP'] : null;
938
+ p.language = d['language'] != null ? d['language'] : null;
939
+ p.version = parseInt(d['version'] != null ? d['version'] : 0, 10) || 0;
940
+ p.lastUpdateTimestamp = parseInt(d['lastUpdateTimestamp'] != null ? d['lastUpdateTimestamp'] : 0, 10) || 0;
941
+ return p;
942
+ }
943
+ }
944
+ // GET_ALL_PRODUCER_INFO(328): group -> the producers that are still alive in it.
945
+ export class ProducerTableInfo {
946
+ data = {};
947
+ static fromDict(d) {
948
+ const b = new ProducerTableInfo();
949
+ const raw = d['data'] || {};
950
+ for (const g of Object.keys(raw)) {
951
+ b.data[g] = (raw[g] || []).map((p) => ProducerInfo.fromDict(p));
952
+ }
953
+ return b;
954
+ }
955
+ static decode(data) {
956
+ return ProducerTableInfo.fromDict(RemotingSerializable.decode(data));
957
+ }
958
+ }
959
+ // HARuntimeInfo.HAConnectionRuntimeInfo (one HA connection to a slave).
960
+ export class HAConnectionRuntimeInfo {
961
+ addr;
962
+ slaveAckOffset;
963
+ diff;
964
+ inSync;
965
+ transferredByteInSecond;
966
+ transferFromWhere;
967
+ constructor() {
968
+ this.addr = null;
969
+ this.slaveAckOffset = 0;
970
+ this.diff = 0;
971
+ this.inSync = false;
972
+ this.transferredByteInSecond = 0;
973
+ this.transferFromWhere = 0;
974
+ }
975
+ static fromDict(d) {
976
+ const c = new HAConnectionRuntimeInfo();
977
+ c.addr = d['addr'] != null ? d['addr'] : null;
978
+ c.slaveAckOffset = parseInt(d['slaveAckOffset'] != null ? d['slaveAckOffset'] : 0, 10) || 0;
979
+ c.diff = parseInt(d['diff'] != null ? d['diff'] : 0, 10) || 0;
980
+ c.inSync = d['inSync'] === true;
981
+ c.transferredByteInSecond = parseInt(d['transferredByteInSecond'] != null ? d['transferredByteInSecond'] : 0, 10) || 0;
982
+ c.transferFromWhere = parseInt(d['transferFromWhere'] != null ? d['transferFromWhere'] : 0, 10) || 0;
983
+ return c;
984
+ }
985
+ }
986
+ // HARuntimeInfo.HAClientRuntimeInfo (the HA client on a slave). Java's field is
987
+ // isActivated: fastjson writes `activated` from the isXxx getter; accept both
988
+ // spellings when reading broker data back.
989
+ export class HAClientRuntimeInfo {
990
+ masterAddr;
991
+ transferredByteInSecond;
992
+ maxOffset;
993
+ lastReadTimestamp;
994
+ lastWriteTimestamp;
995
+ masterFlushOffset;
996
+ isActivated;
997
+ constructor() {
998
+ this.masterAddr = null;
999
+ this.transferredByteInSecond = 0;
1000
+ this.maxOffset = 0;
1001
+ this.lastReadTimestamp = 0;
1002
+ this.lastWriteTimestamp = 0;
1003
+ this.masterFlushOffset = 0;
1004
+ this.isActivated = false;
1005
+ }
1006
+ static fromDict(d) {
1007
+ const c = new HAClientRuntimeInfo();
1008
+ c.masterAddr = d['masterAddr'] != null ? d['masterAddr'] : null;
1009
+ c.transferredByteInSecond = parseInt(d['transferredByteInSecond'] != null ? d['transferredByteInSecond'] : 0, 10) || 0;
1010
+ c.maxOffset = parseInt(d['maxOffset'] != null ? d['maxOffset'] : 0, 10) || 0;
1011
+ c.lastReadTimestamp = parseInt(d['lastReadTimestamp'] != null ? d['lastReadTimestamp'] : 0, 10) || 0;
1012
+ c.lastWriteTimestamp = parseInt(d['lastWriteTimestamp'] != null ? d['lastWriteTimestamp'] : 0, 10) || 0;
1013
+ c.masterFlushOffset = parseInt(d['masterFlushOffset'] != null ? d['masterFlushOffset'] : 0, 10) || 0;
1014
+ c.isActivated = d['isActivated'] === true || d['activated'] === true;
1015
+ return c;
1016
+ }
1017
+ }
1018
+ // GET_BROKER_HA_STATUS(907).
1019
+ export class HARuntimeInfo {
1020
+ master;
1021
+ masterCommitLogMaxOffset;
1022
+ inSyncSlaveNums;
1023
+ haConnectionInfo;
1024
+ haClientRuntimeInfo;
1025
+ constructor() {
1026
+ this.master = false;
1027
+ this.masterCommitLogMaxOffset = 0;
1028
+ this.inSyncSlaveNums = 0;
1029
+ this.haConnectionInfo = [];
1030
+ this.haClientRuntimeInfo = new HAClientRuntimeInfo();
1031
+ }
1032
+ static fromDict(d) {
1033
+ const b = new HARuntimeInfo();
1034
+ b.master = d['master'] === true;
1035
+ b.masterCommitLogMaxOffset = parseInt(d['masterCommitLogMaxOffset'] != null ? d['masterCommitLogMaxOffset'] : 0, 10) || 0;
1036
+ b.inSyncSlaveNums = parseInt(d['inSyncSlaveNums'] != null ? d['inSyncSlaveNums'] : 0, 10) || 0;
1037
+ b.haConnectionInfo = (d['haConnectionInfo'] || []).map((c) => HAConnectionRuntimeInfo.fromDict(c));
1038
+ if (d['haClientRuntimeInfo']) {
1039
+ b.haClientRuntimeInfo = HAClientRuntimeInfo.fromDict(d['haClientRuntimeInfo']);
1040
+ }
1041
+ return b;
1042
+ }
1043
+ static decode(data) {
1044
+ return HARuntimeInfo.fromDict(RemotingSerializable.decode(data));
1045
+ }
1046
+ }
1047
+ // One epoch entry of the broker's commitlog epoch cache. Java default:
1048
+ // LAST_EPOCH_END_OFFSET = Long.MAX_VALUE.
1049
+ export const LAST_EPOCH_END_OFFSET = 9223372036854775807;
1050
+ export class EpochEntry {
1051
+ epoch;
1052
+ startOffset;
1053
+ endOffset;
1054
+ constructor() {
1055
+ this.epoch = 0;
1056
+ this.startOffset = 0;
1057
+ this.endOffset = LAST_EPOCH_END_OFFSET;
1058
+ }
1059
+ static fromDict(d) {
1060
+ const e = new EpochEntry();
1061
+ e.epoch = parseInt(d['epoch'] != null ? d['epoch'] : 0, 10) || 0;
1062
+ e.startOffset = parseInt(d['startOffset'] != null ? d['startOffset'] : 0, 10) || 0;
1063
+ e.endOffset = d['endOffset'] != null
1064
+ ? parseInt(d['endOffset'], 10) : LAST_EPOCH_END_OFFSET;
1065
+ if (e.endOffset == null || Number.isNaN(e.endOffset))
1066
+ e.endOffset = LAST_EPOCH_END_OFFSET;
1067
+ return e;
1068
+ }
1069
+ }
1070
+ // GET_BROKER_EPOCH_CACHE(1007).
1071
+ export class EpochEntryCache {
1072
+ clusterName;
1073
+ brokerName;
1074
+ brokerId;
1075
+ epochList;
1076
+ maxOffset;
1077
+ constructor() {
1078
+ this.clusterName = null;
1079
+ this.brokerName = null;
1080
+ this.brokerId = 0;
1081
+ this.epochList = [];
1082
+ this.maxOffset = 0;
1083
+ }
1084
+ static fromDict(d) {
1085
+ const b = new EpochEntryCache();
1086
+ b.clusterName = d['clusterName'] != null ? d['clusterName'] : null;
1087
+ b.brokerName = d['brokerName'] != null ? d['brokerName'] : null;
1088
+ b.brokerId = parseInt(d['brokerId'] != null ? d['brokerId'] : 0, 10) || 0;
1089
+ b.epochList = (d['epochList'] || []).map((e) => EpochEntry.fromDict(e));
1090
+ b.maxOffset = parseInt(d['maxOffset'] != null ? d['maxOffset'] : 0, 10) || 0;
1091
+ return b;
1092
+ }
1093
+ static decode(data) {
1094
+ return EpochEntryCache.fromDict(RemotingSerializable.decode(data));
1095
+ }
1096
+ }
1097
+ // CONTROLLER_ELECT_MASTER(1002) broker-set answer. JSON object keys are
1098
+ // strings; Java holds Map<Long, String>, so the keys are parsed back to numbers.
1099
+ export class BrokerMemberGroup {
1100
+ cluster;
1101
+ brokerName;
1102
+ brokerAddrs = {};
1103
+ constructor() {
1104
+ this.cluster = null;
1105
+ this.brokerName = null;
1106
+ }
1107
+ static fromDict(d) {
1108
+ const b = new BrokerMemberGroup();
1109
+ b.cluster = d['cluster'] != null ? d['cluster'] : null;
1110
+ b.brokerName = d['brokerName'] != null ? d['brokerName'] : null;
1111
+ const raw = d['brokerAddrs'] || {};
1112
+ for (const k of Object.keys(raw))
1113
+ b.brokerAddrs[parseInt(k, 10)] = raw[k];
1114
+ return b;
1115
+ }
1116
+ static decode(data) {
1117
+ return BrokerMemberGroup.fromDict(RemotingSerializable.decode(data));
1118
+ }
1119
+ }
1120
+ export default {
1121
+ KVTable, TopicList, GroupList, LockBatchRequestBody, LockBatchResponseBody, UnlockBatchRequestBody,
1122
+ GetConsumerListByGroupResponseBody, CheckClientRequestBody, ClusterInfo, Connection, ConsumerConnection,
1123
+ ProducerConnection, QueryConsumeTimeSpanBody, ConsumeStatus, ConsumeStatsList, ResetOffsetBody,
1124
+ MessageQueueForC, ResetOffsetBodyForC, GetConsumerStatusBody, ProcessQueueInfo, CMResult,
1125
+ ConsumeMessageDirectlyResult, ConsumerRunningInfo, TopicConfig, TopicConfigSerializeWrapper,
1126
+ OffsetWrapper, ConsumeStats, BrokerStatsData, StatsItem, MessageRequestMode, QueryMsgResponseBody, QueryResult,
1127
+ messageQueueKey, parseMessageQueueKey, decodeMessageQueueMap,
1128
+ QueryCorrectionOffsetBody, ProducerInfo, ProducerTableInfo,
1129
+ HAConnectionRuntimeInfo, HAClientRuntimeInfo, HARuntimeInfo,
1130
+ EpochEntry, EpochEntryCache, BrokerMemberGroup,
1131
+ };