rocketmq-client-nodejs 0.0.0 → 1.0.0

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 (165) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +69 -1
  3. package/dist/client/BaseClient.d.ts +92 -0
  4. package/dist/client/BaseClient.js +308 -0
  5. package/dist/client/ClientId.d.ts +24 -0
  6. package/dist/client/ClientId.js +33 -0
  7. package/dist/client/Logger.d.ts +24 -0
  8. package/dist/client/Logger.js +34 -0
  9. package/dist/client/RpcClient.d.ts +47 -0
  10. package/dist/client/RpcClient.js +208 -0
  11. package/dist/client/RpcClientManager.d.ts +41 -0
  12. package/dist/client/RpcClientManager.js +139 -0
  13. package/dist/client/SessionCredentials.d.ts +21 -0
  14. package/dist/client/SessionCredentials.js +19 -0
  15. package/dist/client/Settings.d.ts +30 -0
  16. package/dist/client/Settings.js +38 -0
  17. package/dist/client/TelemetrySession.d.ts +27 -0
  18. package/dist/client/TelemetrySession.js +101 -0
  19. package/dist/client/UserAgent.d.ts +25 -0
  20. package/dist/client/UserAgent.js +47 -0
  21. package/dist/client/index.d.ts +26 -0
  22. package/dist/client/index.js +43 -0
  23. package/dist/consumer/Consumer.d.ts +32 -0
  24. package/dist/consumer/Consumer.js +96 -0
  25. package/dist/consumer/FilterExpression.d.ts +25 -0
  26. package/dist/consumer/FilterExpression.js +40 -0
  27. package/dist/consumer/SimpleConsumer.d.ts +47 -8
  28. package/dist/consumer/SimpleConsumer.js +105 -27
  29. package/dist/consumer/SimpleSubscriptionSettings.d.ts +28 -0
  30. package/dist/consumer/SimpleSubscriptionSettings.js +57 -0
  31. package/dist/consumer/SubscriptionLoadBalancer.d.ts +23 -0
  32. package/dist/consumer/SubscriptionLoadBalancer.js +46 -0
  33. package/dist/consumer/index.d.ts +21 -0
  34. package/dist/consumer/index.js +38 -0
  35. package/dist/exception/BadRequestException.d.ts +20 -0
  36. package/dist/exception/BadRequestException.js +28 -0
  37. package/dist/exception/ClientException.d.ts +20 -0
  38. package/dist/exception/ClientException.js +31 -0
  39. package/dist/exception/ForbiddenException.d.ts +20 -0
  40. package/dist/exception/ForbiddenException.js +28 -0
  41. package/dist/exception/InternalErrorException.d.ts +20 -0
  42. package/dist/exception/InternalErrorException.js +28 -0
  43. package/dist/exception/NotFoundException.d.ts +20 -0
  44. package/dist/exception/NotFoundException.js +28 -0
  45. package/dist/exception/PayloadTooLargeException.d.ts +20 -0
  46. package/dist/exception/PayloadTooLargeException.js +28 -0
  47. package/dist/exception/PaymentRequiredException.d.ts +20 -0
  48. package/dist/exception/PaymentRequiredException.js +28 -0
  49. package/dist/exception/ProxyTimeoutException.d.ts +20 -0
  50. package/dist/exception/ProxyTimeoutException.js +28 -0
  51. package/dist/exception/RequestHeaderFieldsTooLargeException.d.ts +20 -0
  52. package/dist/exception/RequestHeaderFieldsTooLargeException.js +28 -0
  53. package/dist/exception/StatusChecker.d.ts +20 -0
  54. package/dist/exception/StatusChecker.js +98 -0
  55. package/dist/exception/TooManyRequestsException.d.ts +20 -0
  56. package/dist/exception/TooManyRequestsException.js +28 -0
  57. package/dist/exception/UnauthorizedException.d.ts +20 -0
  58. package/dist/exception/UnauthorizedException.js +28 -0
  59. package/dist/exception/UnsupportedException.d.ts +20 -0
  60. package/dist/exception/UnsupportedException.js +28 -0
  61. package/dist/exception/index.d.ts +29 -0
  62. package/dist/exception/index.js +46 -0
  63. package/dist/index.d.ts +22 -3
  64. package/dist/index.js +23 -4
  65. package/dist/message/Message.d.ts +37 -0
  66. package/dist/message/Message.js +43 -0
  67. package/dist/message/MessageId.d.ts +59 -0
  68. package/dist/message/MessageId.js +123 -0
  69. package/dist/message/MessageView.d.ts +39 -0
  70. package/dist/message/MessageView.js +90 -0
  71. package/dist/message/PublishingMessage.d.ts +30 -0
  72. package/dist/message/PublishingMessage.js +98 -0
  73. package/dist/message/index.d.ts +20 -0
  74. package/dist/message/index.js +37 -0
  75. package/dist/producer/Producer.d.ts +42 -0
  76. package/dist/producer/Producer.js +242 -1
  77. package/dist/producer/PublishingLoadBalancer.d.ts +24 -0
  78. package/dist/producer/PublishingLoadBalancer.js +82 -0
  79. package/dist/producer/PublishingSettings.d.ts +28 -0
  80. package/dist/producer/PublishingSettings.js +70 -0
  81. package/dist/producer/SendReceipt.d.ts +28 -0
  82. package/dist/producer/SendReceipt.js +57 -0
  83. package/dist/producer/Transaction.d.ts +28 -0
  84. package/dist/producer/Transaction.js +64 -0
  85. package/dist/producer/TransactionChecker.d.ts +21 -0
  86. package/dist/producer/TransactionChecker.js +19 -0
  87. package/dist/producer/index.d.ts +21 -0
  88. package/dist/producer/index.js +39 -0
  89. package/dist/retry/ExponentialBackoffRetryPolicy.d.ts +27 -0
  90. package/dist/retry/ExponentialBackoffRetryPolicy.js +67 -0
  91. package/dist/retry/RetryPolicy.d.ts +46 -0
  92. package/dist/retry/RetryPolicy.js +19 -0
  93. package/dist/retry/index.d.ts +18 -0
  94. package/dist/retry/index.js +35 -0
  95. package/dist/route/Broker.d.ts +25 -0
  96. package/dist/route/Broker.js +40 -0
  97. package/dist/route/Endpoints.d.ts +30 -0
  98. package/dist/route/Endpoints.js +71 -0
  99. package/dist/route/MessageQueue.d.ts +27 -0
  100. package/dist/route/MessageQueue.js +47 -0
  101. package/dist/route/TopicRouteData.d.ts +24 -0
  102. package/dist/route/TopicRouteData.js +37 -0
  103. package/dist/route/index.d.ts +20 -0
  104. package/dist/route/index.js +37 -0
  105. package/dist/util/index.d.ts +36 -0
  106. package/dist/util/index.js +88 -0
  107. package/package.json +12 -5
  108. package/src/client/BaseClient.ts +384 -0
  109. package/src/client/ClientId.ts +31 -0
  110. package/src/client/Logger.ts +35 -0
  111. package/src/client/RpcClient.ts +245 -0
  112. package/src/client/RpcClientManager.ts +173 -0
  113. package/src/client/SessionCredentials.ts +22 -0
  114. package/src/client/Settings.ts +45 -0
  115. package/src/client/TelemetrySession.ts +118 -0
  116. package/src/client/UserAgent.ts +45 -0
  117. package/src/client/index.ts +27 -0
  118. package/src/consumer/Consumer.ts +111 -0
  119. package/src/consumer/FilterExpression.ts +42 -0
  120. package/src/consumer/SimpleConsumer.ts +133 -20
  121. package/src/consumer/SimpleSubscriptionSettings.ts +65 -0
  122. package/src/consumer/SubscriptionLoadBalancer.ts +47 -0
  123. package/src/consumer/index.ts +22 -0
  124. package/src/exception/BadRequestException.ts +25 -0
  125. package/src/exception/ClientException.ts +29 -0
  126. package/src/exception/ForbiddenException.ts +25 -0
  127. package/src/exception/InternalErrorException.ts +25 -0
  128. package/src/exception/NotFoundException.ts +25 -0
  129. package/src/exception/PayloadTooLargeException.ts +25 -0
  130. package/src/exception/PaymentRequiredException.ts +25 -0
  131. package/src/exception/ProxyTimeoutException.ts +25 -0
  132. package/src/exception/RequestHeaderFieldsTooLargeException.ts +25 -0
  133. package/src/exception/StatusChecker.ts +94 -0
  134. package/src/exception/TooManyRequestsException.ts +25 -0
  135. package/src/exception/UnauthorizedException.ts +25 -0
  136. package/src/exception/UnsupportedException.ts +25 -0
  137. package/src/exception/index.ts +30 -0
  138. package/src/index.ts +23 -3
  139. package/src/message/Message.ts +51 -0
  140. package/src/message/MessageId.ts +123 -0
  141. package/src/message/MessageView.ts +94 -0
  142. package/src/message/PublishingMessage.ts +102 -0
  143. package/src/message/index.ts +21 -0
  144. package/src/producer/Producer.ts +291 -0
  145. package/src/producer/PublishingLoadBalancer.ts +85 -0
  146. package/src/producer/PublishingSettings.ts +79 -0
  147. package/src/producer/SendReceipt.ts +60 -0
  148. package/src/producer/Transaction.ts +70 -0
  149. package/src/producer/TransactionChecker.ts +23 -0
  150. package/src/producer/index.ts +23 -0
  151. package/src/retry/ExponentialBackoffRetryPolicy.ts +76 -0
  152. package/src/retry/RetryPolicy.ts +51 -0
  153. package/src/retry/index.ts +19 -0
  154. package/src/route/Broker.ts +39 -0
  155. package/src/route/Endpoints.ts +70 -0
  156. package/src/route/MessageQueue.ts +49 -0
  157. package/src/route/TopicRouteData.ts +38 -0
  158. package/src/route/index.ts +21 -0
  159. package/src/util/index.ts +83 -0
  160. package/dist/grpc/MessagingServiceClient.d.ts +0 -9
  161. package/dist/grpc/MessagingServiceClient.js +0 -13
  162. package/dist/model/SessionCredentials.d.ts +0 -5
  163. package/dist/model/SessionCredentials.js +0 -3
  164. package/src/grpc/MessagingServiceClient.ts +0 -17
  165. package/src/model/SessionCredentials.ts +0 -5
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Transaction = void 0;
20
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
21
+ const message_1 = require("../message");
22
+ class Transaction {
23
+ static MAX_MESSAGE_NUM = 1;
24
+ #producer;
25
+ #messageMap = new Map();
26
+ #messageSendReceiptMap = new Map();
27
+ constructor(producer) {
28
+ this.#producer = producer;
29
+ }
30
+ tryAddMessage(message) {
31
+ if (this.#messageMap.size >= Transaction.MAX_MESSAGE_NUM) {
32
+ throw new TypeError(`Message in transaction has exceeded the threshold=${Transaction.MAX_MESSAGE_NUM}`);
33
+ }
34
+ const publishingMessage = new message_1.PublishingMessage(message, this.#producer.publishingSettings, true);
35
+ this.#messageMap.set(publishingMessage.messageId, publishingMessage);
36
+ return publishingMessage;
37
+ }
38
+ tryAddReceipt(publishingMessage, sendReceipt) {
39
+ if (!this.#messageMap.has(publishingMessage.messageId)) {
40
+ throw new TypeError('Message not in transaction');
41
+ }
42
+ this.#messageSendReceiptMap.set(publishingMessage.messageId, sendReceipt);
43
+ }
44
+ async commit() {
45
+ if (this.#messageSendReceiptMap.size === 0) {
46
+ throw new TypeError('Transactional message has not been sent yet');
47
+ }
48
+ for (const [messageId, sendReceipt] of this.#messageSendReceiptMap.entries()) {
49
+ const publishingMessage = this.#messageMap.get(messageId);
50
+ await this.#producer.endTransaction(sendReceipt.endpoints, publishingMessage, sendReceipt.messageId, sendReceipt.transactionId, definition_pb_1.TransactionResolution.COMMIT);
51
+ }
52
+ }
53
+ async rollback() {
54
+ if (this.#messageSendReceiptMap.size === 0) {
55
+ throw new TypeError('Transactional message has not been sent yet');
56
+ }
57
+ for (const [messageId, sendReceipt] of this.#messageSendReceiptMap.entries()) {
58
+ const publishingMessage = this.#messageMap.get(messageId);
59
+ await this.#producer.endTransaction(sendReceipt.endpoints, publishingMessage, sendReceipt.messageId, sendReceipt.transactionId, definition_pb_1.TransactionResolution.ROLLBACK);
60
+ }
61
+ }
62
+ }
63
+ exports.Transaction = Transaction;
64
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVHJhbnNhY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJvZHVjZXIvVHJhbnNhY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsZ0ZBQXFGO0FBQ3JGLHdDQUErRDtBQUkvRCxNQUFhLFdBQVc7SUFDdEIsTUFBTSxDQUFVLGVBQWUsR0FBRyxDQUFDLENBQUM7SUFDM0IsU0FBUyxDQUFXO0lBQ3BCLFdBQVcsR0FBRyxJQUFJLEdBQUcsRUFBNkIsQ0FBQztJQUNuRCxzQkFBc0IsR0FBRyxJQUFJLEdBQUcsRUFBdUIsQ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dEYsQ0FBQztJQUNILENBQUM7O0FBOUNILGtDQStDQyJ9
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { TransactionResolution } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ import { MessageView } from '../message';
19
+ export interface TransactionChecker {
20
+ check(messageView: MessageView): Promise<TransactionResolution>;
21
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVHJhbnNhY3Rpb25DaGVja2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Byb2R1Y2VyL1RyYW5zYWN0aW9uQ2hlY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHIn0=
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './Producer';
18
+ export * from './PublishingLoadBalancer';
19
+ export * from './PublishingSettings';
20
+ export * from './SendReceipt';
21
+ export * from './TransactionChecker';
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ __exportStar(require("./Producer"), exports);
34
+ __exportStar(require("./PublishingLoadBalancer"), exports);
35
+ __exportStar(require("./PublishingSettings"), exports);
36
+ __exportStar(require("./SendReceipt"), exports);
37
+ // export * from './Transaction';
38
+ __exportStar(require("./TransactionChecker"), exports);
39
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJvZHVjZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILDZDQUEyQjtBQUMzQiwyREFBeUM7QUFDekMsdURBQXFDO0FBQ3JDLGdEQUE4QjtBQUM5QixpQ0FBaUM7QUFDakMsdURBQXFDIn0=
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { RetryPolicy as RetryPolicyPB } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ import { RetryPolicy } from './RetryPolicy';
19
+ export declare class ExponentialBackoffRetryPolicy implements RetryPolicy {
20
+ #private;
21
+ constructor(maxAttempts: number, initialBackoff?: number, maxBackoff?: number, backoffMultiplier?: number);
22
+ static immediatelyRetryPolicy(maxAttempts: number): ExponentialBackoffRetryPolicy;
23
+ getMaxAttempts(): number;
24
+ getNextAttemptDelay(attempt: number): number;
25
+ inheritBackoff(retryPolicy: RetryPolicyPB): RetryPolicy;
26
+ toProtobuf(): RetryPolicyPB;
27
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.ExponentialBackoffRetryPolicy = void 0;
23
+ const node_assert_1 = __importDefault(require("node:assert"));
24
+ const duration_pb_1 = require("google-protobuf/google/protobuf/duration_pb");
25
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
26
+ class ExponentialBackoffRetryPolicy {
27
+ #maxAttempts;
28
+ // seconds
29
+ #initialBackoff;
30
+ #maxBackoff;
31
+ #backoffMultiplier;
32
+ constructor(maxAttempts, initialBackoff = 0, maxBackoff = 0, backoffMultiplier = 1) {
33
+ this.#maxAttempts = maxAttempts;
34
+ this.#initialBackoff = initialBackoff;
35
+ this.#maxBackoff = maxBackoff;
36
+ this.#backoffMultiplier = backoffMultiplier;
37
+ }
38
+ static immediatelyRetryPolicy(maxAttempts) {
39
+ return new ExponentialBackoffRetryPolicy(maxAttempts, 0, 0, 1);
40
+ }
41
+ getMaxAttempts() {
42
+ return this.#maxAttempts;
43
+ }
44
+ getNextAttemptDelay(attempt) {
45
+ (0, node_assert_1.default)(attempt > 0, 'attempt must be positive');
46
+ const delay = Math.min(this.#initialBackoff * Math.pow(this.#backoffMultiplier, 1.0 * (attempt - 1)), this.#maxBackoff);
47
+ if (delay <= 0) {
48
+ return 0;
49
+ }
50
+ return delay;
51
+ }
52
+ inheritBackoff(retryPolicy) {
53
+ (0, node_assert_1.default)(retryPolicy.getStrategyCase() === definition_pb_1.RetryPolicy.StrategyCase.EXPONENTIAL_BACKOFF, 'strategy must be exponential backoff');
54
+ const backoff = retryPolicy.getExponentialBackoff().toObject();
55
+ return new ExponentialBackoffRetryPolicy(this.#maxAttempts, backoff.initial?.seconds, backoff.max?.seconds, backoff.multiplier);
56
+ }
57
+ toProtobuf() {
58
+ return new definition_pb_1.RetryPolicy()
59
+ .setMaxAttempts(this.#maxAttempts)
60
+ .setExponentialBackoff(new definition_pb_1.ExponentialBackoff()
61
+ .setInitial(new duration_pb_1.Duration().setSeconds(this.#initialBackoff))
62
+ .setMax(new duration_pb_1.Duration().setSeconds(this.#maxBackoff))
63
+ .setMultiplier(this.#backoffMultiplier));
64
+ }
65
+ }
66
+ exports.ExponentialBackoffRetryPolicy = ExponentialBackoffRetryPolicy;
67
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRXhwb25lbnRpYWxCYWNrb2ZmUmV0cnlQb2xpY3ku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QVUsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUM7YUFDbkQsYUFBYSxDQUFDLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUM7SUFDakQsQ0FBQztDQUNGO0FBbERELHNFQWtEQyJ9
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { RetryPolicy as RetryPolicyPB } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ /**
19
+ * Internal interface for retry policy.
20
+ */
21
+ export interface RetryPolicy {
22
+ /**
23
+ * Get the max attempt times for retry.
24
+ *
25
+ * @return max attempt times.
26
+ */
27
+ getMaxAttempts(): number;
28
+ /**
29
+ * Get await time after current attempts, the attempt index starts at 1.
30
+ *
31
+ * @param attempt current attempt.
32
+ * @return await time in seconds.
33
+ */
34
+ getNextAttemptDelay(attempt: number): number;
35
+ /**
36
+ * Update the retry backoff strategy and generate a new one.
37
+ *
38
+ * @param retryPolicy retry policy which contains the backoff strategy.
39
+ * @return the new retry policy.
40
+ */
41
+ inheritBackoff(retryPolicy: RetryPolicyPB): RetryPolicy;
42
+ /**
43
+ * Convert to RetryPolicyPB
44
+ */
45
+ toProtobuf(): RetryPolicyPB;
46
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmV0cnlQb2xpY3kuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmV0cnkvUmV0cnlQb2xpY3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRyJ9
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './ExponentialBackoffRetryPolicy';
18
+ export * from './RetryPolicy';
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ __exportStar(require("./ExponentialBackoffRetryPolicy"), exports);
34
+ __exportStar(require("./RetryPolicy"), exports);
35
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcmV0cnkvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILGtFQUFnRDtBQUNoRCxnREFBOEIifQ==
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Broker as BrokerPB } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ import { Endpoints } from './Endpoints';
19
+ export declare class Broker implements BrokerPB.AsObject {
20
+ name: string;
21
+ id: number;
22
+ endpoints: Endpoints;
23
+ constructor(broker: BrokerPB.AsObject);
24
+ toProtobuf(): BrokerPB;
25
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Broker = void 0;
20
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
21
+ const Endpoints_1 = require("./Endpoints");
22
+ class Broker {
23
+ name;
24
+ id;
25
+ endpoints;
26
+ constructor(broker) {
27
+ this.name = broker.name;
28
+ this.id = broker.id;
29
+ this.endpoints = new Endpoints_1.Endpoints(broker.endpoints);
30
+ }
31
+ toProtobuf() {
32
+ const broker = new definition_pb_1.Broker();
33
+ broker.setName(this.name);
34
+ broker.setId(this.id);
35
+ broker.setEndpoints(this.endpoints.toProtobuf());
36
+ return broker;
37
+ }
38
+ }
39
+ exports.Broker = Broker;
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQnJva2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JvdXRlL0Jyb2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSCxnRkFBa0Y7QUFDbEYsMkNBQXdDO0FBRXhDLE1BQWEsTUFBTTtJQUNqQixJQUFJLENBQVM7SUFDYixFQUFFLENBQVM7SUFDWCxTQUFTLENBQVk7SUFFckIsWUFBWSxNQUF5QjtRQUNuQyxJQUFJLENBQUMsSUFBSSxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUM7UUFDeEIsSUFBSSxDQUFDLEVBQUUsR0FBRyxNQUFNLENBQUMsRUFBRSxDQUFDO1FBQ3BCLElBQUksQ0FBQyxTQUFTLEdBQUcsSUFBSSxxQkFBUyxDQUFDLE1BQU0sQ0FBQyxTQUFVLENBQUMsQ0FBQztJQUNwRCxDQUFDO0lBRUQsVUFBVTtRQUNSLE1BQU0sTUFBTSxHQUFHLElBQUksc0JBQVEsRUFBRSxDQUFDO1FBQzlCLE1BQU0sQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQzFCLE1BQU0sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDO1FBQ3RCLE1BQU0sQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLEVBQUUsQ0FBQyxDQUFDO1FBQ2pELE9BQU8sTUFBTSxDQUFDO0lBQ2hCLENBQUM7Q0FDRjtBQWxCRCx3QkFrQkMifQ==
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Address, AddressScheme, Endpoints as EndpointsPB } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ export declare class Endpoints {
19
+ readonly addressesList: Address.AsObject[];
20
+ readonly scheme: AddressScheme;
21
+ /**
22
+ * URI path for grpc target, e.g:
23
+ * 127.0.0.1:10911[,127.0.0.2:10912]
24
+ */
25
+ readonly facade: string;
26
+ constructor(endpoints: string | EndpointsPB.AsObject);
27
+ getGrpcTarget(): string;
28
+ toString(): string;
29
+ toProtobuf(): EndpointsPB;
30
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.Endpoints = void 0;
20
+ const node_net_1 = require("node:net");
21
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
22
+ const DEFAULT_PORT = 80;
23
+ class Endpoints {
24
+ addressesList;
25
+ scheme;
26
+ /**
27
+ * URI path for grpc target, e.g:
28
+ * 127.0.0.1:10911[,127.0.0.2:10912]
29
+ */
30
+ facade;
31
+ constructor(endpoints) {
32
+ if (typeof endpoints === 'string') {
33
+ const splits = endpoints.split(';');
34
+ this.addressesList = [];
35
+ for (const endpoint of splits) {
36
+ const [host, port] = endpoint.split(':');
37
+ if ((0, node_net_1.isIPv4)(host)) {
38
+ this.scheme = definition_pb_1.AddressScheme.IPV4;
39
+ }
40
+ else if ((0, node_net_1.isIPv6)(host)) {
41
+ this.scheme = definition_pb_1.AddressScheme.IPV6;
42
+ }
43
+ else {
44
+ this.scheme = definition_pb_1.AddressScheme.DOMAIN_NAME;
45
+ }
46
+ this.addressesList.push({ host, port: parseInt(port) || DEFAULT_PORT });
47
+ }
48
+ }
49
+ else {
50
+ this.scheme = endpoints.scheme;
51
+ this.addressesList = endpoints.addressesList;
52
+ }
53
+ this.facade = this.addressesList.map(addr => `${addr.host}:${addr.port}`).join(',');
54
+ }
55
+ getGrpcTarget() {
56
+ return this.facade;
57
+ }
58
+ toString() {
59
+ return this.facade;
60
+ }
61
+ toProtobuf() {
62
+ const endpoints = new definition_pb_1.Endpoints();
63
+ endpoints.setScheme(this.scheme);
64
+ for (const address of this.addressesList) {
65
+ endpoints.addAddresses().setHost(address.host).setPort(address.port);
66
+ }
67
+ return endpoints;
68
+ }
69
+ }
70
+ exports.Endpoints = Endpoints;
71
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW5kcG9pbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL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Q0QsOEJBK0NDIn0=
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { MessageQueue as MessageQueuePB, MessageType, Permission, Resource } from '../../proto/apache/rocketmq/v2/definition_pb';
18
+ import { Broker } from './Broker';
19
+ export declare class MessageQueue {
20
+ topic: Resource.AsObject;
21
+ queueId: number;
22
+ broker: Broker;
23
+ permission: Permission;
24
+ acceptMessageTypesList: MessageType[];
25
+ constructor(messageQueue: MessageQueuePB);
26
+ toProtobuf(): MessageQueuePB;
27
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.MessageQueue = void 0;
20
+ const definition_pb_1 = require("../../proto/apache/rocketmq/v2/definition_pb");
21
+ const util_1 = require("../util");
22
+ const Broker_1 = require("./Broker");
23
+ class MessageQueue {
24
+ topic;
25
+ queueId;
26
+ broker;
27
+ permission;
28
+ acceptMessageTypesList;
29
+ constructor(messageQueue) {
30
+ this.topic = messageQueue.getTopic().toObject();
31
+ this.queueId = messageQueue.getId();
32
+ this.permission = messageQueue.getPermission();
33
+ this.acceptMessageTypesList = messageQueue.getAcceptMessageTypesList();
34
+ this.broker = new Broker_1.Broker(messageQueue.getBroker().toObject());
35
+ }
36
+ toProtobuf() {
37
+ const messageQueue = new definition_pb_1.MessageQueue();
38
+ messageQueue.setId(this.queueId);
39
+ messageQueue.setTopic((0, util_1.createResource)(this.topic.name));
40
+ messageQueue.setBroker(this.broker.toProtobuf());
41
+ messageQueue.setPermission(this.permission);
42
+ messageQueue.setAcceptMessageTypesList(this.acceptMessageTypesList);
43
+ return messageQueue;
44
+ }
45
+ }
46
+ exports.MessageQueue = MessageQueue;
47
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZVF1ZXVlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3JvdXRlL01lc3NhZ2VRdWV1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSCxnRkFHc0Q7QUFDdEQsa0NBQXlDO0FBQ3pDLHFDQUFrQztBQUVsQyxNQUFhLFlBQVk7SUFDdkIsS0FBSyxDQUFvQjtJQUN6QixPQUFPLENBQVM7SUFDaEIsTUFBTSxDQUFTO0lBQ2YsVUFBVSxDQUFhO0lBQ3ZCLHNCQUFzQixDQUFnQjtJQUV0QyxZQUFZLFlBQTRCO1FBQ3RDLElBQUksQ0FBQyxLQUFLLEdBQUcsWUFBWSxDQUFDLFFBQVEsRUFBRyxDQUFDLFFBQVEsRUFBRSxDQUFDO1FBQ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