rocketmq-client-nodejs 1.0.8 → 1.1.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 (159) hide show
  1. package/README.md +61 -0
  2. package/dist/client/BaseClient.d.ts +36 -1
  3. package/dist/client/BaseClient.js +176 -12
  4. package/dist/client/RpcClient.js +14 -2
  5. package/dist/client/RpcClientManager.d.ts +5 -0
  6. package/dist/client/RpcClientManager.js +25 -8
  7. package/dist/client/TelemetrySession.js +45 -10
  8. package/dist/consumer/ConsumeService.d.ts +2 -1
  9. package/dist/consumer/ConsumeService.js +7 -3
  10. package/dist/consumer/ConsumeTask.d.ts +6 -1
  11. package/dist/consumer/ConsumeTask.js +36 -5
  12. package/dist/consumer/Consumer.d.ts +13 -5
  13. package/dist/consumer/Consumer.js +85 -24
  14. package/dist/consumer/FifoConsumeService.d.ts +2 -1
  15. package/dist/consumer/FifoConsumeService.js +3 -3
  16. package/dist/consumer/LiteFifoConsumeService.d.ts +2 -1
  17. package/dist/consumer/LiteFifoConsumeService.js +3 -3
  18. package/dist/consumer/LitePushConsumerImpl.d.ts +12 -1
  19. package/dist/consumer/LitePushConsumerImpl.js +19 -4
  20. package/dist/consumer/LiteSimpleConsumer.d.ts +177 -0
  21. package/dist/consumer/LiteSimpleConsumer.js +126 -0
  22. package/dist/consumer/LiteSimpleConsumerImpl.d.ts +133 -0
  23. package/dist/consumer/LiteSimpleConsumerImpl.js +187 -0
  24. package/dist/consumer/LiteStandardConsumeService.d.ts +2 -1
  25. package/dist/consumer/LiteStandardConsumeService.js +3 -3
  26. package/dist/consumer/LiteSubscriptionManager.d.ts +27 -6
  27. package/dist/consumer/LiteSubscriptionManager.js +32 -24
  28. package/dist/consumer/ProcessQueue.d.ts +10 -0
  29. package/dist/consumer/ProcessQueue.js +43 -5
  30. package/dist/consumer/PushConsumer.d.ts +17 -0
  31. package/dist/consumer/PushConsumer.js +43 -4
  32. package/dist/consumer/PushConsumerGaugeObserver.d.ts +33 -0
  33. package/dist/consumer/PushConsumerGaugeObserver.js +60 -0
  34. package/dist/consumer/PushSubscriptionSettings.d.ts +8 -1
  35. package/dist/consumer/PushSubscriptionSettings.js +33 -6
  36. package/dist/consumer/SimpleConsumer.js +10 -1
  37. package/dist/consumer/StandardConsumeService.d.ts +2 -1
  38. package/dist/consumer/StandardConsumeService.js +3 -3
  39. package/dist/consumer/index.d.ts +1 -0
  40. package/dist/consumer/index.js +2 -1
  41. package/dist/exception/PayloadEmptyException.d.ts +20 -0
  42. package/dist/exception/PayloadEmptyException.js +28 -0
  43. package/dist/exception/StatusChecker.js +8 -1
  44. package/dist/exception/index.d.ts +1 -0
  45. package/dist/exception/index.js +2 -1
  46. package/dist/hook/Attribute.d.ts +26 -0
  47. package/dist/hook/Attribute.js +37 -0
  48. package/dist/hook/AttributeKey.d.ts +32 -0
  49. package/dist/hook/AttributeKey.js +43 -0
  50. package/dist/hook/CompositedMessageInterceptor.d.ts +31 -0
  51. package/dist/hook/CompositedMessageInterceptor.js +84 -0
  52. package/dist/hook/InflightRequestCountInterceptor.d.ts +28 -0
  53. package/dist/hook/InflightRequestCountInterceptor.js +44 -0
  54. package/dist/hook/MessageHookPoints.d.ts +54 -0
  55. package/dist/hook/MessageHookPoints.js +59 -0
  56. package/dist/hook/MessageHookPointsStatus.d.ts +24 -0
  57. package/dist/hook/MessageHookPointsStatus.js +29 -0
  58. package/dist/hook/MessageInterceptor.d.ts +34 -0
  59. package/dist/hook/MessageInterceptor.js +19 -0
  60. package/dist/hook/MessageInterceptorContext.d.ts +31 -0
  61. package/dist/hook/MessageInterceptorContext.js +19 -0
  62. package/dist/hook/MessageInterceptorContextImpl.d.ts +39 -0
  63. package/dist/hook/MessageInterceptorContextImpl.js +57 -0
  64. package/dist/hook/MessageMeterInterceptor.d.ts +39 -0
  65. package/dist/hook/MessageMeterInterceptor.js +149 -0
  66. package/dist/hook/index.d.ts +26 -0
  67. package/dist/hook/index.js +43 -0
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +2 -1
  70. package/dist/metrics/ClientMeter.d.ts +42 -0
  71. package/dist/metrics/ClientMeter.js +75 -0
  72. package/dist/metrics/ClientMeterManager.d.ts +42 -0
  73. package/dist/metrics/ClientMeterManager.js +127 -0
  74. package/dist/metrics/EmptyGaugeObserver.d.ts +28 -0
  75. package/dist/metrics/EmptyGaugeObserver.js +34 -0
  76. package/dist/metrics/GaugeEnum.d.ts +32 -0
  77. package/dist/metrics/GaugeEnum.js +37 -0
  78. package/dist/metrics/GaugeObserver.d.ts +29 -0
  79. package/dist/metrics/GaugeObserver.js +19 -0
  80. package/dist/metrics/HistogramEnum.d.ts +54 -0
  81. package/dist/metrics/HistogramEnum.js +71 -0
  82. package/dist/metrics/InvocationStatus.d.ts +26 -0
  83. package/dist/metrics/InvocationStatus.js +33 -0
  84. package/dist/metrics/Metric.d.ts +30 -0
  85. package/dist/metrics/Metric.js +44 -0
  86. package/dist/metrics/MetricLabels.d.ts +27 -0
  87. package/dist/metrics/MetricLabels.js +34 -0
  88. package/dist/metrics/index.d.ts +25 -0
  89. package/dist/metrics/index.js +42 -0
  90. package/dist/producer/Producer.js +33 -5
  91. package/dist/producer/PublishingLoadBalancer.js +9 -3
  92. package/dist/retry/CustomizedBackoffRetryPolicy.d.ts +37 -0
  93. package/dist/retry/CustomizedBackoffRetryPolicy.js +72 -0
  94. package/dist/retry/ExponentialBackoffRetryPolicy.js +10 -6
  95. package/dist/retry/RetryPolicy.d.ts +1 -1
  96. package/dist/retry/index.d.ts +1 -0
  97. package/dist/retry/index.js +2 -1
  98. package/dist/route/Endpoints.d.ts +6 -0
  99. package/dist/route/Endpoints.js +56 -4
  100. package/dist/route/IpNameResolver.d.ts +28 -0
  101. package/dist/route/IpNameResolver.js +104 -0
  102. package/dist/util/Semaphore.d.ts +47 -0
  103. package/dist/util/Semaphore.js +82 -0
  104. package/package.json +6 -2
  105. package/src/client/BaseClient.ts +202 -12
  106. package/src/client/RpcClient.ts +14 -1
  107. package/src/client/RpcClientManager.ts +27 -8
  108. package/src/client/TelemetrySession.ts +47 -9
  109. package/src/consumer/ConsumeService.ts +9 -2
  110. package/src/consumer/ConsumeTask.ts +43 -3
  111. package/src/consumer/Consumer.ts +103 -23
  112. package/src/consumer/FifoConsumeService.ts +4 -2
  113. package/src/consumer/LiteFifoConsumeService.ts +4 -2
  114. package/src/consumer/LitePushConsumerImpl.ts +21 -3
  115. package/src/consumer/LiteSimpleConsumer.ts +251 -0
  116. package/src/consumer/LiteSimpleConsumerImpl.ts +221 -0
  117. package/src/consumer/LiteStandardConsumeService.ts +4 -2
  118. package/src/consumer/LiteSubscriptionManager.ts +63 -36
  119. package/src/consumer/ProcessQueue.ts +44 -1
  120. package/src/consumer/PushConsumer.ts +54 -2
  121. package/src/consumer/PushConsumerGaugeObserver.ts +60 -0
  122. package/src/consumer/PushSubscriptionSettings.ts +38 -7
  123. package/src/consumer/SimpleConsumer.ts +9 -0
  124. package/src/consumer/StandardConsumeService.ts +4 -2
  125. package/src/consumer/index.ts +1 -0
  126. package/src/exception/PayloadEmptyException.ts +25 -0
  127. package/src/exception/StatusChecker.ts +7 -0
  128. package/src/exception/index.ts +1 -0
  129. package/src/hook/Attribute.ts +36 -0
  130. package/src/hook/AttributeKey.ts +42 -0
  131. package/src/hook/CompositedMessageInterceptor.ts +92 -0
  132. package/src/hook/InflightRequestCountInterceptor.ts +46 -0
  133. package/src/hook/MessageHookPoints.ts +55 -0
  134. package/src/hook/MessageHookPointsStatus.ts +25 -0
  135. package/src/hook/MessageInterceptor.ts +35 -0
  136. package/src/hook/MessageInterceptorContext.ts +33 -0
  137. package/src/hook/MessageInterceptorContextImpl.ts +68 -0
  138. package/src/hook/MessageMeterInterceptor.ts +162 -0
  139. package/src/hook/index.ts +27 -0
  140. package/src/index.ts +1 -0
  141. package/src/metrics/ClientMeter.ts +81 -0
  142. package/src/metrics/ClientMeterManager.ts +145 -0
  143. package/src/metrics/EmptyGaugeObserver.ts +36 -0
  144. package/src/metrics/GaugeEnum.ts +33 -0
  145. package/src/metrics/GaugeObserver.ts +32 -0
  146. package/src/metrics/HistogramEnum.ts +69 -0
  147. package/src/metrics/InvocationStatus.ts +28 -0
  148. package/src/metrics/Metric.ts +42 -0
  149. package/src/metrics/MetricLabels.ts +31 -0
  150. package/src/metrics/index.ts +26 -0
  151. package/src/producer/Producer.ts +37 -6
  152. package/src/producer/PublishingLoadBalancer.ts +8 -2
  153. package/src/retry/CustomizedBackoffRetryPolicy.ts +81 -0
  154. package/src/retry/ExponentialBackoffRetryPolicy.ts +11 -6
  155. package/src/retry/RetryPolicy.ts +1 -1
  156. package/src/retry/index.ts +1 -0
  157. package/src/route/Endpoints.ts +52 -3
  158. package/src/route/IpNameResolver.ts +119 -0
  159. package/src/util/Semaphore.ts +82 -0
@@ -0,0 +1,28 @@
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 { MessageInterceptorContext } from './MessageInterceptorContext';
18
+ import { GeneralMessage, MessageInterceptor } from './MessageInterceptor';
19
+ /**
20
+ * Interceptor which counts the in-flight receive requests, mirroring
21
+ * org.apache.rocketmq.client.java.hook.InflightRequestCountInterceptor.
22
+ */
23
+ export declare class InflightRequestCountInterceptor implements MessageInterceptor {
24
+ #private;
25
+ doBefore(context: MessageInterceptorContext, _messages: GeneralMessage[]): void;
26
+ doAfter(context: MessageInterceptorContext, _messages: GeneralMessage[]): void;
27
+ getInflightReceiveRequestCount(): number;
28
+ }
@@ -0,0 +1,44 @@
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.InflightRequestCountInterceptor = void 0;
20
+ const MessageHookPoints_1 = require("./MessageHookPoints");
21
+ /**
22
+ * Interceptor which counts the in-flight receive requests, mirroring
23
+ * org.apache.rocketmq.client.java.hook.InflightRequestCountInterceptor.
24
+ */
25
+ class InflightRequestCountInterceptor {
26
+ #inflightReceiveRequestCount = 0;
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ doBefore(context, _messages) {
29
+ if (context.getMessageHookPoints() === MessageHookPoints_1.MessageHookPoints.RECEIVE) {
30
+ this.#inflightReceiveRequestCount++;
31
+ }
32
+ }
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
+ doAfter(context, _messages) {
35
+ if (context.getMessageHookPoints() === MessageHookPoints_1.MessageHookPoints.RECEIVE) {
36
+ this.#inflightReceiveRequestCount--;
37
+ }
38
+ }
39
+ getInflightReceiveRequestCount() {
40
+ return this.#inflightReceiveRequestCount;
41
+ }
42
+ }
43
+ exports.InflightRequestCountInterceptor = InflightRequestCountInterceptor;
44
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSW5mbGlnaHRSZXF1ZXN0Q291bnRJbnRlcmNlcHRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ob29rL0luZmxpZ2h0UmVxdWVzdENvdW50SW50ZXJjZXB0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7O0FBRUgsMkRBQXdEO0FBSXhEOzs7R0FHRztBQUNILE1BQWEsK0JBQStCO0lBQzFDLDRCQUE0QixHQUFHLENBQUMsQ0FBQztJQUVqQyw2REFBNkQ7SUFDN0QsUUFBUSxDQUFDLE9BQWtDLEVBQUUsU0FBMkI7UUFDdEUsSUFBSSxPQUFPLENBQUMsb0JBQW9CLEVBQUUsS0FBSyxxQ0FBaUIsQ0FBQyxPQUFPLEVBQUUsQ0FBQztZQUNqRSxJQUFJLENBQUMsNEJBQTRCLEVBQUUsQ0FBQztRQUN0QyxDQUFDO0lBQ0gsQ0FBQztJQUVELDZEQUE2RDtJQUM3RCxPQUFPLENBQUMsT0FBa0MsRUFBRSxTQUEyQjtRQUNyRSxJQUFJLE9BQU8sQ0FBQyxvQkFBb0IsRUFBRSxLQUFLLHFDQUFpQixDQUFDLE9BQU8sRUFBRSxDQUFDO1lBQ2pFLElBQUksQ0FBQyw0QkFBNEIsRUFBRSxDQUFDO1FBQ3RDLENBQUM7SUFDSCxDQUFDO0lBRUQsOEJBQThCO1FBQzVCLE9BQU8sSUFBSSxDQUFDLDRCQUE0QixDQUFDO0lBQzNDLENBQUM7Q0FDRjtBQXBCRCwwRUFvQkMifQ==
@@ -0,0 +1,54 @@
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
+ /**
18
+ * Hook points at which {@link MessageInterceptor}s are invoked, mirroring
19
+ * org.apache.rocketmq.client.java.hook.MessageHookPoints.
20
+ */
21
+ export declare enum MessageHookPoints {
22
+ /**
23
+ * The hook point of message publishing.
24
+ */
25
+ SEND = "SEND",
26
+ /**
27
+ * The hook point of message reception.
28
+ */
29
+ RECEIVE = "RECEIVE",
30
+ /**
31
+ * The hook point of message consumption.
32
+ */
33
+ CONSUME = "CONSUME",
34
+ /**
35
+ * The hook point of message ack acknowledgement.
36
+ */
37
+ ACK = "ACK",
38
+ /**
39
+ * The hook point of message changing invisible duration.
40
+ */
41
+ CHANGE_INVISIBLE_DURATION = "CHANGE_INVISIBLE_DURATION",
42
+ /**
43
+ * The hook point of message transaction commit.
44
+ */
45
+ COMMIT_TRANSACTION = "COMMIT_TRANSACTION",
46
+ /**
47
+ * The hook point of message transaction rollback.
48
+ */
49
+ ROLLBACK_TRANSACTION = "ROLLBACK_TRANSACTION",
50
+ /**
51
+ * The hook point of forwarding message to DLQ.
52
+ */
53
+ FORWARD_TO_DLQ = "FORWARD_TO_DLQ"
54
+ }
@@ -0,0 +1,59 @@
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.MessageHookPoints = void 0;
20
+ /**
21
+ * Hook points at which {@link MessageInterceptor}s are invoked, mirroring
22
+ * org.apache.rocketmq.client.java.hook.MessageHookPoints.
23
+ */
24
+ var MessageHookPoints;
25
+ (function (MessageHookPoints) {
26
+ /**
27
+ * The hook point of message publishing.
28
+ */
29
+ MessageHookPoints["SEND"] = "SEND";
30
+ /**
31
+ * The hook point of message reception.
32
+ */
33
+ MessageHookPoints["RECEIVE"] = "RECEIVE";
34
+ /**
35
+ * The hook point of message consumption.
36
+ */
37
+ MessageHookPoints["CONSUME"] = "CONSUME";
38
+ /**
39
+ * The hook point of message ack acknowledgement.
40
+ */
41
+ MessageHookPoints["ACK"] = "ACK";
42
+ /**
43
+ * The hook point of message changing invisible duration.
44
+ */
45
+ MessageHookPoints["CHANGE_INVISIBLE_DURATION"] = "CHANGE_INVISIBLE_DURATION";
46
+ /**
47
+ * The hook point of message transaction commit.
48
+ */
49
+ MessageHookPoints["COMMIT_TRANSACTION"] = "COMMIT_TRANSACTION";
50
+ /**
51
+ * The hook point of message transaction rollback.
52
+ */
53
+ MessageHookPoints["ROLLBACK_TRANSACTION"] = "ROLLBACK_TRANSACTION";
54
+ /**
55
+ * The hook point of forwarding message to DLQ.
56
+ */
57
+ MessageHookPoints["FORWARD_TO_DLQ"] = "FORWARD_TO_DLQ";
58
+ })(MessageHookPoints || (exports.MessageHookPoints = MessageHookPoints = {}));
59
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUhvb2tQb2ludHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9vay9NZXNzYWdlSG9va1BvaW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSDs7O0dBR0c7QUFDSCxJQUFZLGlCQWlDWDtBQWpDRCxXQUFZLGlCQUFpQjtJQUMzQjs7T0FFRztJQUNILGtDQUFhLENBQUE7SUFDYjs7T0FFRztJQUNILHdDQUFtQixDQUFBO0lBQ25COztPQUVHO0lBQ0gsd0NBQW1CLENBQUE7SUFDbkI7O09BRUc7SUFDSCxnQ0FBVyxDQUFBO0lBQ1g7O09BRUc7SUFDSCw0RUFBdUQsQ0FBQTtJQUN2RDs7T0FFRztJQUNILDhEQUF5QyxDQUFBO0lBQ3pDOztPQUVHO0lBQ0gsa0VBQTZDLENBQUE7SUFDN0M7O09BRUc7SUFDSCxzREFBaUMsQ0FBQTtBQUNuQyxDQUFDLEVBakNXLGlCQUFpQixpQ0FBakIsaUJBQWlCLFFBaUM1QiJ9
@@ -0,0 +1,24 @@
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
+ /**
18
+ * Status of a hook point invocation, mirroring
19
+ * org.apache.rocketmq.client.java.hook.MessageHookPointsStatus.
20
+ */
21
+ export declare enum MessageHookPointsStatus {
22
+ OK = "OK",
23
+ ERROR = "ERROR"
24
+ }
@@ -0,0 +1,29 @@
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.MessageHookPointsStatus = void 0;
20
+ /**
21
+ * Status of a hook point invocation, mirroring
22
+ * org.apache.rocketmq.client.java.hook.MessageHookPointsStatus.
23
+ */
24
+ var MessageHookPointsStatus;
25
+ (function (MessageHookPointsStatus) {
26
+ MessageHookPointsStatus["OK"] = "OK";
27
+ MessageHookPointsStatus["ERROR"] = "ERROR";
28
+ })(MessageHookPointsStatus || (exports.MessageHookPointsStatus = MessageHookPointsStatus = {}));
29
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUhvb2tQb2ludHNTdGF0dXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9vay9NZXNzYWdlSG9va1BvaW50c1N0YXR1cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFFSDs7O0dBR0c7QUFDSCxJQUFZLHVCQUdYO0FBSEQsV0FBWSx1QkFBdUI7SUFDakMsb0NBQVMsQ0FBQTtJQUNULDBDQUFlLENBQUE7QUFDakIsQ0FBQyxFQUhXLHVCQUF1Qix1Q0FBdkIsdUJBQXVCLFFBR2xDIn0=
@@ -0,0 +1,34 @@
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 { MessageView } from '../message/MessageView';
18
+ import { MessageInterceptorContext } from './MessageInterceptorContext';
19
+ /**
20
+ * Message passed to interceptors: either an outgoing message or a received one,
21
+ * mirroring org.apache.rocketmq.client.java.message.GeneralMessage.
22
+ */
23
+ export type GeneralMessage = MessageView | {
24
+ topic: string;
25
+ };
26
+ /**
27
+ * Interface for intercepting ingoing/outgoing message before/after they are
28
+ * dispatched by client, mirroring
29
+ * org.apache.rocketmq.client.java.hook.MessageInterceptor.
30
+ */
31
+ export interface MessageInterceptor {
32
+ doBefore(context: MessageInterceptorContext, messages: GeneralMessage[]): void;
33
+ doAfter(context: MessageInterceptorContext, messages: GeneralMessage[]): void;
34
+ }
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUludGVyY2VwdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hvb2svTWVzc2FnZUludGVyY2VwdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUcifQ==
@@ -0,0 +1,31 @@
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 { Attribute } from './Attribute';
18
+ import { AttributeKey } from './AttributeKey';
19
+ import { MessageHookPoints } from './MessageHookPoints';
20
+ import { MessageHookPointsStatus } from './MessageHookPointsStatus';
21
+ /**
22
+ * Context carried through the message interceptor chain, mirroring
23
+ * org.apache.rocketmq.client.java.hook.MessageInterceptorContext.
24
+ */
25
+ export interface MessageInterceptorContext {
26
+ getMessageHookPoints(): MessageHookPoints;
27
+ getStatus(): MessageHookPointsStatus | undefined;
28
+ putAttribute<T>(key: AttributeKey<T>, value: Attribute<T>): void;
29
+ getAttribute<T>(key: AttributeKey<T>): Attribute<T> | undefined;
30
+ getAttributes(): Map<AttributeKey<any>, Attribute<any>>;
31
+ }
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUludGVyY2VwdG9yQ29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ob29rL01lc3NhZ2VJbnRlcmNlcHRvckNvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRyJ9
@@ -0,0 +1,39 @@
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 { Attribute } from './Attribute';
18
+ import { AttributeKey } from './AttributeKey';
19
+ import { MessageHookPoints } from './MessageHookPoints';
20
+ import { MessageHookPointsStatus } from './MessageHookPointsStatus';
21
+ import { MessageInterceptorContext } from './MessageInterceptorContext';
22
+ /**
23
+ * Default {@link MessageInterceptorContext} implementation, mirroring
24
+ * org.apache.rocketmq.client.java.hook.MessageInterceptorContextImpl.
25
+ */
26
+ export declare class MessageInterceptorContextImpl implements MessageInterceptorContext {
27
+ #private;
28
+ constructor(messageHookPoints: MessageHookPoints, status?: MessageHookPointsStatus, attributes?: Map<AttributeKey<any>, Attribute<any>>);
29
+ /**
30
+ * Derive a new context from an existing one with the given status, e.g. once the
31
+ * outcome of the intercepted operation is known.
32
+ */
33
+ static withStatus(context: MessageInterceptorContext, status: MessageHookPointsStatus): MessageInterceptorContextImpl;
34
+ getMessageHookPoints(): MessageHookPoints;
35
+ getStatus(): MessageHookPointsStatus | undefined;
36
+ putAttribute<T>(key: AttributeKey<T>, value: Attribute<T>): void;
37
+ getAttribute<T>(key: AttributeKey<T>): Attribute<T> | undefined;
38
+ getAttributes(): Map<AttributeKey<any>, Attribute<any>>;
39
+ }
@@ -0,0 +1,57 @@
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.MessageInterceptorContextImpl = void 0;
20
+ /**
21
+ * Default {@link MessageInterceptorContext} implementation, mirroring
22
+ * org.apache.rocketmq.client.java.hook.MessageInterceptorContextImpl.
23
+ */
24
+ class MessageInterceptorContextImpl {
25
+ #messageHookPoints;
26
+ #status;
27
+ #attributes;
28
+ constructor(messageHookPoints, status, attributes) {
29
+ this.#messageHookPoints = messageHookPoints;
30
+ this.#status = status;
31
+ this.#attributes = new Map(attributes ?? []);
32
+ }
33
+ /**
34
+ * Derive a new context from an existing one with the given status, e.g. once the
35
+ * outcome of the intercepted operation is known.
36
+ */
37
+ static withStatus(context, status) {
38
+ return new MessageInterceptorContextImpl(context.getMessageHookPoints(), status, context.getAttributes());
39
+ }
40
+ getMessageHookPoints() {
41
+ return this.#messageHookPoints;
42
+ }
43
+ getStatus() {
44
+ return this.#status;
45
+ }
46
+ putAttribute(key, value) {
47
+ this.#attributes.set(key, value);
48
+ }
49
+ getAttribute(key) {
50
+ return this.#attributes.get(key);
51
+ }
52
+ getAttributes() {
53
+ return this.#attributes;
54
+ }
55
+ }
56
+ exports.MessageInterceptorContextImpl = MessageInterceptorContextImpl;
57
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZUludGVyY2VwdG9yQ29udGV4dEltcGwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9vay9NZXNzYWdlSW50ZXJjZXB0b3JDb250ZXh0SW1wbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFRSDs7O0dBR0c7QUFDSCxNQUFhLDZCQUE2QjtJQUMvQixrQkFBa0IsQ0FBb0I7SUFDdEMsT0FBTyxDQUFzQztJQUM3QyxXQUFXLENBQXlDO0lBRTdELFlBQVksaUJBQW9DLEVBQzlDLE1BQWdDLEVBQ2hDLFVBQW1EO1FBQ25ELElBQUksQ0FBQyxrQkFBa0IsR0FBRyxpQkFBaUIsQ0FBQztRQUM1QyxJQUFJLENBQUMsT0FBTyxHQUFHLE1BQU0sQ0FBQztRQUN0QixJQUFJLENBQUMsV0FBVyxHQUFHLElBQUksR0FBRyxDQUFDLFVBQVUsSUFBSSxFQUFFLENBQUMsQ0FBQztJQUMvQyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsTUFBTSxDQUFDLFVBQVUsQ0FBQyxPQUFrQyxFQUFFLE1BQStCO1FBQ25GLE9BQU8sSUFBSSw2QkFBNkIsQ0FBQyxPQUFPLENBQUMsb0JBQW9CLEVBQUUsRUFBRSxNQUFNLEVBQUUsT0FBTyxDQUFDLGFBQWEsRUFBRSxDQUFDLENBQUM7SUFDNUcsQ0FBQztJQUVELG9CQUFvQjtRQUNsQixPQUFPLElBQUksQ0FBQyxrQkFBa0IsQ0FBQztJQUNqQyxDQUFDO0lBRUQsU0FBUztRQUNQLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQztJQUN0QixDQUFDO0lBRUQsWUFBWSxDQUFJLEdBQW9CLEVBQUUsS0FBbUI7UUFDdkQsSUFBSSxDQUFDLFdBQVcsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLEtBQUssQ0FBQyxDQUFDO0lBQ25DLENBQUM7SUFFRCxZQUFZLENBQUksR0FBb0I7UUFDbEMsT0FBTyxJQUFJLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQTZCLENBQUM7SUFDL0QsQ0FBQztJQUVELGFBQWE7UUFDWCxPQUFPLElBQUksQ0FBQyxXQUFXLENBQUM7SUFDMUIsQ0FBQztDQUNGO0FBeENELHNFQXdDQyJ9
@@ -0,0 +1,39 @@
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 { AttributeKey, MessageInterceptor, MessageInterceptorContext } from './';
18
+ import { GeneralMessage } from './MessageInterceptor';
19
+ import { ClientMeterManager } from '../metrics/ClientMeterManager';
20
+ /**
21
+ * Records the four RocketMQ histograms around the SEND / RECEIVE / CONSUME hook
22
+ * points, mirroring org.apache.rocketmq.client.java.metrics.MessageMeterInterceptor.
23
+ *
24
+ * Unlike Java (which wires an AuthInterceptor + IpNameResolverFactory onto the
25
+ * export channel), the Node client signs each export request via a per-call
26
+ * metadata provider (see {@link ClientMeterManager}), so no auth plumbing is
27
+ * needed here.
28
+ */
29
+ export declare class MessageMeterInterceptor implements MessageInterceptor {
30
+ #private;
31
+ private readonly meterManager;
32
+ private readonly clientId;
33
+ private readonly getConsumerGroup;
34
+ static readonly SEND_STOPWATCH_KEY: AttributeKey<number>;
35
+ static readonly CONSUME_STOPWATCH_KEY: AttributeKey<number>;
36
+ constructor(meterManager: ClientMeterManager, clientId: string, getConsumerGroup: () => string | undefined);
37
+ doBefore(context: MessageInterceptorContext, messages: GeneralMessage[]): void;
38
+ doAfter(context: MessageInterceptorContext, messages: GeneralMessage[]): void;
39
+ }
@@ -0,0 +1,149 @@
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.MessageMeterInterceptor = void 0;
20
+ const _1 = require("./");
21
+ const MetricLabels_1 = require("../metrics/MetricLabels");
22
+ const InvocationStatus_1 = require("../metrics/InvocationStatus");
23
+ const HistogramEnum_1 = require("../metrics/HistogramEnum");
24
+ /**
25
+ * Records the four RocketMQ histograms around the SEND / RECEIVE / CONSUME hook
26
+ * points, mirroring org.apache.rocketmq.client.java.metrics.MessageMeterInterceptor.
27
+ *
28
+ * Unlike Java (which wires an AuthInterceptor + IpNameResolverFactory onto the
29
+ * export channel), the Node client signs each export request via a per-call
30
+ * metadata provider (see {@link ClientMeterManager}), so no auth plumbing is
31
+ * needed here.
32
+ */
33
+ class MessageMeterInterceptor {
34
+ meterManager;
35
+ clientId;
36
+ getConsumerGroup;
37
+ static SEND_STOPWATCH_KEY = _1.AttributeKey.create('send_stopwatch');
38
+ static CONSUME_STOPWATCH_KEY = _1.AttributeKey.create('consume_stopwatch');
39
+ constructor(meterManager, clientId, getConsumerGroup) {
40
+ this.meterManager = meterManager;
41
+ this.clientId = clientId;
42
+ this.getConsumerGroup = getConsumerGroup;
43
+ }
44
+ doBefore(context, messages) {
45
+ if (!this.meterManager.isEnabled()) {
46
+ return;
47
+ }
48
+ switch (context.getMessageHookPoints()) {
49
+ case _1.MessageHookPoints.SEND:
50
+ context.putAttribute(MessageMeterInterceptor.SEND_STOPWATCH_KEY, _1.Attribute.create(Date.now()));
51
+ break;
52
+ case _1.MessageHookPoints.CONSUME: {
53
+ const consumerGroup = this.getConsumerGroup();
54
+ if (!consumerGroup) {
55
+ break;
56
+ }
57
+ const message = messages[0];
58
+ if (!message || !message.decodeTimestamp) {
59
+ break;
60
+ }
61
+ const latency = Date.now() - message.decodeTimestamp.getTime();
62
+ const attributes = this.#consumerAttributes(message.topic, consumerGroup);
63
+ this.meterManager.record(HistogramEnum_1.HistogramEnum.AWAIT_TIME, attributes, latency);
64
+ context.putAttribute(MessageMeterInterceptor.CONSUME_STOPWATCH_KEY, _1.Attribute.create(Date.now()));
65
+ break;
66
+ }
67
+ default:
68
+ break;
69
+ }
70
+ }
71
+ doAfter(context, messages) {
72
+ if (!this.meterManager.isEnabled()) {
73
+ return;
74
+ }
75
+ const status = context.getStatus();
76
+ const invocationStatus = status === _1.MessageHookPointsStatus.OK ? InvocationStatus_1.InvocationStatus.SUCCESS : InvocationStatus_1.InvocationStatus.FAILURE;
77
+ switch (context.getMessageHookPoints()) {
78
+ case _1.MessageHookPoints.SEND: {
79
+ const attr = context.getAttribute(MessageMeterInterceptor.SEND_STOPWATCH_KEY);
80
+ if (!attr) {
81
+ break;
82
+ }
83
+ const message = messages[0];
84
+ if (!message) {
85
+ break;
86
+ }
87
+ const cost = Date.now() - attr.get();
88
+ const attributes = {
89
+ [MetricLabels_1.MetricLabels.TOPIC]: message.topic,
90
+ [MetricLabels_1.MetricLabels.CLIENT_ID]: this.clientId,
91
+ [MetricLabels_1.MetricLabels.INVOCATION_STATUS]: invocationStatus.name,
92
+ };
93
+ this.meterManager.record(HistogramEnum_1.HistogramEnum.SEND_COST_TIME, attributes, cost);
94
+ break;
95
+ }
96
+ case _1.MessageHookPoints.RECEIVE: {
97
+ const consumerGroup = this.getConsumerGroup();
98
+ if (!consumerGroup) {
99
+ break;
100
+ }
101
+ const message = messages[0];
102
+ if (!message || !message.transportDeliveryTimestamp) {
103
+ break;
104
+ }
105
+ const latency = Date.now() - message.transportDeliveryTimestamp.getTime();
106
+ if (latency < 0) {
107
+ break;
108
+ }
109
+ const attributes = this.#consumerAttributes(message.topic, consumerGroup);
110
+ this.meterManager.record(HistogramEnum_1.HistogramEnum.DELIVERY_LATENCY, attributes, latency);
111
+ break;
112
+ }
113
+ case _1.MessageHookPoints.CONSUME: {
114
+ const consumerGroup = this.getConsumerGroup();
115
+ if (!consumerGroup) {
116
+ break;
117
+ }
118
+ const attr = context.getAttribute(MessageMeterInterceptor.CONSUME_STOPWATCH_KEY);
119
+ if (!attr) {
120
+ break;
121
+ }
122
+ const message = messages[0];
123
+ if (!message) {
124
+ break;
125
+ }
126
+ const cost = Date.now() - attr.get();
127
+ const attributes = {
128
+ [MetricLabels_1.MetricLabels.TOPIC]: message.topic,
129
+ [MetricLabels_1.MetricLabels.CLIENT_ID]: this.clientId,
130
+ [MetricLabels_1.MetricLabels.CONSUMER_GROUP]: consumerGroup,
131
+ [MetricLabels_1.MetricLabels.INVOCATION_STATUS]: invocationStatus.name,
132
+ };
133
+ this.meterManager.record(HistogramEnum_1.HistogramEnum.PROCESS_TIME, attributes, cost);
134
+ break;
135
+ }
136
+ default:
137
+ break;
138
+ }
139
+ }
140
+ #consumerAttributes(topic, consumerGroup) {
141
+ return {
142
+ [MetricLabels_1.MetricLabels.TOPIC]: topic,
143
+ [MetricLabels_1.MetricLabels.CLIENT_ID]: this.clientId,
144
+ [MetricLabels_1.MetricLabels.CONSUMER_GROUP]: consumerGroup,
145
+ };
146
+ }
147
+ }
148
+ exports.MessageMeterInterceptor = MessageMeterInterceptor;
149
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWVzc2FnZU1ldGVySW50ZXJjZXB0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9vay9NZXNzYWdlTWV0ZXJJbnRlcmNlcHRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFHSCx5QkFBd0k7QUFFeEksMERBQXVEO0FBQ3ZELGtFQUErRDtBQUMvRCw0REFBeUQ7QUFjekQ7Ozs7Ozs7O0dBUUc7QUFDSCxNQUFhLHVCQUF1QjtJQUtmO0lBQ0E7SUFDQTtJQU5uQixNQUFNLENBQVUsa0JBQWtCLEdBQUcsZUFBWSxDQUFDLE1BQU0sQ0FBUyxnQkFBZ0IsQ0FBQyxDQUFDO0lBQ25GLE1BQU0sQ0FBVSxxQkFBcUIsR0FBRyxlQUFZLENB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