kafka-ts 1.1.2-beta.2 → 1.1.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection.js +1 -0
- package/dist/producer/producer.js +3 -6
- package/dist/utils/lock.js +1 -1
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -73,6 +73,7 @@ class Connection {
|
|
|
73
73
|
this.socket.once('error', reject);
|
|
74
74
|
});
|
|
75
75
|
this.socket.removeAllListeners('error');
|
|
76
|
+
this.socket.on('error', error => logger_1.log.debug('Socket error', { error }));
|
|
76
77
|
this.socket.on('data', (data) => this.handleData(data));
|
|
77
78
|
this.socket.once('close', async () => {
|
|
78
79
|
Object.values(this.queue).forEach(({ reject }) => {
|
|
@@ -45,9 +45,7 @@ class Producer {
|
|
|
45
45
|
const { allowTopicAutoCreation } = this.options;
|
|
46
46
|
const defaultTimestamp = BigInt(Date.now());
|
|
47
47
|
const topics = new Set(messages.map((message) => message.topic));
|
|
48
|
-
await this.lock.acquire([...topics],
|
|
49
|
-
await this.metadata.fetchMetadataIfNecessary({ topics, allowTopicAutoCreation });
|
|
50
|
-
});
|
|
48
|
+
await this.lock.acquire([...topics].map((topic) => `metadata:${topic}`), () => this.metadata.fetchMetadataIfNecessary({ topics, allowTopicAutoCreation }));
|
|
51
49
|
const partitionedMessages = messages.map((message) => {
|
|
52
50
|
message.partition = this.partition(message);
|
|
53
51
|
return message;
|
|
@@ -55,8 +53,7 @@ class Producer {
|
|
|
55
53
|
const nodeTopicPartitionMessages = (0, messages_to_topic_partition_leaders_1.distributeMessagesToTopicPartitionLeaders)(partitionedMessages, this.metadata.getTopicPartitionLeaderIds());
|
|
56
54
|
try {
|
|
57
55
|
await Promise.all(Object.entries(nodeTopicPartitionMessages).map(async ([nodeId, topicPartitionMessages]) => {
|
|
58
|
-
|
|
59
|
-
await this.lock.acquire(lockKeys, async () => {
|
|
56
|
+
await this.lock.acquire([`node:${nodeId}`], async () => {
|
|
60
57
|
const topicData = Object.entries(topicPartitionMessages).map(([topic, partitionMessages]) => ({
|
|
61
58
|
name: topic,
|
|
62
59
|
partitionData: Object.entries(partitionMessages).map(([partition, messages]) => {
|
|
@@ -99,7 +96,7 @@ class Producer {
|
|
|
99
96
|
await this.cluster.sendRequestToNode(parseInt(nodeId))(api_1.API.PRODUCE, {
|
|
100
97
|
transactionalId: null,
|
|
101
98
|
acks,
|
|
102
|
-
timeoutMs:
|
|
99
|
+
timeoutMs: 30000,
|
|
103
100
|
topicData,
|
|
104
101
|
});
|
|
105
102
|
topicData.forEach(({ name, partitionData }) => {
|
package/dist/utils/lock.js
CHANGED