Skip to content

Commit 2f8f7fe

Browse files
committed
Change kafkaJs -> kafkaJS for uniformity
1 parent 265c2ce commit 2f8f7fe

File tree

12 files changed

+67
-67
lines changed

12 files changed

+67
-67
lines changed

MIGRATION.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## KafkaJS
44

55

6-
1. Change the import statement, and add a `kafkaJs` block around your configs.
6+
1. Change the import statement, and add a `kafkaJS` block around your configs.
77
```javascript
88
const { Kafka } = require('kafkajs');
99
const kafka = new Kafka({ brokers: ['kafka1:9092', 'kafka2:9092'], /* ... */ });
@@ -12,8 +12,8 @@
1212
to
1313
```javascript
1414
const { Kafka } = require('confluent-kafka-js').KafkaJS;
15-
const kafka = new Kafka({ kafkaJs: { brokers: ['kafka1:9092', 'kafka2:9092'], /* ... */ } });
16-
const producer = kafka.producer({ kafkaJs: { /* ... */, } });
15+
const kafka = new Kafka({ kafkaJS: { brokers: ['kafka1:9092', 'kafka2:9092'], /* ... */ } });
16+
const producer = kafka.producer({ kafkaJS: { /* ... */, } });
1717
```
1818

1919
2. Try running your program. In case a migration is needed, an informative error will be thrown.
@@ -38,15 +38,15 @@
3838
+const { Kafka } = require('confluent-kafka-js').KafkaJS;
3939
4040
const kafka = new Kafka({
41-
+ kafkaJs: {
41+
+ kafkaJS: {
4242
clientId: 'my-app',
4343
brokers: ['kafka1:9092', 'kafka2:9092']
4444
+ }
4545
})
4646
4747
const producerRun = async () => {
4848
- const producer = kafka.producer();
49-
+ const producer = kafka.producer({ kafkaJs: { acks: 1 } });
49+
+ const producer = kafka.producer({ kafkaJS: { acks: 1 } });
5050
await producer.connect();
5151
await producer.send({
5252
topic: 'test-topic',
@@ -61,7 +61,7 @@ const producerRun = async () => {
6161
const consumerRun = async () => {
6262
// Consuming
6363
- const consumer = kafka.consumer({ groupId: 'test-group' });
64-
+ const consumer = kafka.consumer({ kafkaJs: { groupId: 'test-group', fromBeginning: true } });
64+
+ const consumer = kafka.consumer({ kafkaJS: { groupId: 'test-group', fromBeginning: true } });
6565
await consumer.connect();
6666
- await consumer.subscribe({ topic: 'test-topic', fromBeginning: true });
6767
+ await consumer.subscribe({ topic: 'test-topic' });
@@ -84,15 +84,15 @@ producerRun().then(consumerRun).catch(console.error);
8484

8585
#### Configuration changes
8686
```javascript
87-
const kafka = new Kafka({ kafkaJs: { /* common configuration changes */ } });
87+
const kafka = new Kafka({ kafkaJS: { /* common configuration changes */ } });
8888
```
8989
Each allowed config property is discussed in the table below.
9090
If there is any change in semantics or the default values, the property and the change is **highlighted in bold**.
9191

9292
| Property | Default Value | Comment |
9393
|-------------------------------|--------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9494
| **brokers** | null | A list of strings, representing the bootstrap brokers. **A function is no longer allowed as an argument for this.** |
95-
| **ssl** | false | A boolean, set to true if ssl needs to be enabled. **Additional properties like CA, certificate, key, etc. need to be specified outside the kafkaJs block.** |
95+
| **ssl** | false | A boolean, set to true if ssl needs to be enabled. **Additional properties like CA, certificate, key, etc. need to be specified outside the kafkaJS block.** |
9696
| **sasl** | - | An optional object of the form `{ mechanism: 'plain' or 'scram-sha-256' or 'scram-sha-512', username: string, password: string }`. **Additional authentication types are not yet supported.** |
9797
| clientId | "rdkafka" | An optional string used to identify the client. |
9898
| **connectionTimeout** | 1000 | This timeout is not enforced individually, but a sum of `connectionTimeout` and `authenticationTimeout` is enforced together. |
@@ -109,23 +109,23 @@ producerRun().then(consumerRun).catch(console.error);
109109
| **retry.restartOnFailure** | true | Consumer only. **Cannot be changed**. Consumer will always make an attempt to restart. |
110110
| logLevel | `logLevel.INFO` | Decides the severity level of the logger created by the underlying library. A logger created with the `INFO` level will not be able to log `DEBUG` messages later. |
111111
| **socketFactory** | null | **No longer supported.** |
112-
| outer config | {} | The configuration outside the kafkaJs block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
112+
| outer config | {} | The configuration outside the kafkaJS block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
113113

114114

115115
### Producer
116116

117117
#### Producer Configuration Changes
118118

119119
```javascript
120-
const producer = kafka.producer({ kafkaJs: { /* producer-specific configuration changes. */ } });
120+
const producer = kafka.producer({ kafkaJS: { /* producer-specific configuration changes. */ } });
121121
```
122122

123123
Each allowed config property is discussed in the table below.
124124
If there is any change in semantics or the default values, the property and the change is **highlighted in bold**.
125125

126126
| Property | Default Value | Comment |
127127
|-------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
128-
| **createPartitioner** | DefaultPartioner (murmur2_random) - Java client compatible | Custom partitioner support is not yet provided. The default partitioner's behaviour is retained, and a number of partitioners are provided via the `partitioner` property, which is specified outside the `kafkaJs` block. |
128+
| **createPartitioner** | DefaultPartioner (murmur2_random) - Java client compatible | Custom partitioner support is not yet provided. The default partitioner's behaviour is retained, and a number of partitioners are provided via the `partitioner` property, which is specified outside the `kafkaJS` block. |
129129
| **retry** | object | Identical to `retry` in the common configuration. This takes precedence over the common config retry. |
130130
| metadataMaxAge | 5 minutes | Time in milliseconds after which to refresh metadata for known topics |
131131
| allowAutoTopicCreation | true | Determines if a topic should be created if it doesn't exist while producing. |
@@ -136,7 +136,7 @@ producerRun().then(consumerRun).catch(console.error);
136136
| **acks** | -1 | The number of required acks before a Produce succeeds. **This is set on a per-producer level, not on a per `send` level**. -1 denotes it will wait for all brokers in the in-sync replica set. |
137137
| **compression** | CompressionTypes.NONE | Compression codec for Produce messages. **This is set on a per-producer level, not on a per `send` level**. It must be a key of the object CompressionType, namely GZIP, SNAPPY, LZ4, ZSTD or NONE. |
138138
| **timeout** | 30000 | The ack timeout of the producer request in milliseconds. This value is only enforced by the broker. **This is set on a per-producer level, not on a per `send` level**. |
139-
| outer config | {} | The configuration outside the kafkaJs block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
139+
| outer config | {} | The configuration outside the kafkaJS block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
140140

141141

142142

@@ -164,9 +164,9 @@ producerRun().then(consumerRun).catch(console.error);
164164
165165
After:
166166
```javascript
167-
const kafka = new Kafka({ kafkaJs: { /* ... */ }});
167+
const kafka = new Kafka({ kafkaJS: { /* ... */ }});
168168
const producer = kafka.producer({
169-
kafkaJs: {
169+
kafkaJS: {
170170
acks: 1,
171171
compression: CompressionTypes.GZIP|CompressionTypes.SNAPPY|CompressionTypes.LZ4|CompressionTypes.ZSTD|CompressionTypes.NONE,
172172
timeout: 30000,
@@ -187,7 +187,7 @@ producerRun().then(consumerRun).catch(console.error);
187187
#### Consumer Configuration Changes
188188
189189
```javascript
190-
const consumer = kafka.consumer({ kafkaJs: { /* producer-specific configuration changes. */ } });
190+
const consumer = kafka.consumer({ kafkaJS: { /* producer-specific configuration changes. */ } });
191191
```
192192
Each allowed config property is discussed in the table below.
193193
If there is any change in semantics or the default values, the property and the change is **highlighted in bold**.
@@ -211,7 +211,7 @@ producerRun().then(consumerRun).catch(console.error);
211211
| **fromBeginning** | false | If there is initial offset in offset store or the desired offset is out of range, and this is true, we consume the earliest possible offset. **This is set on a per-consumer level, not on a per `subscribe` level**. |
212212
| **autoCommit** | true | Whether to periodically auto-commit offsets to the broker while consuming. **This is set on a per-consumer level, not on a per `run` level**. |
213213
| **autoCommitInterval** | 5000 | Offsets are committed periodically at this interval, if autoCommit is true. **This is set on a per-consumer level, not on a per `run` level. The default value is changed to 5 seconds.**. |
214-
| outer config | {} | The configuration outside the kafkaJs block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
214+
| outer config | {} | The configuration outside the kafkaJS block can contain any of the keys present in the [librdkafka CONFIGURATION table](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md). |
215215
216216
217217
#### Semantic and Per-Method Changes
@@ -237,7 +237,7 @@ producerRun().then(consumerRun).catch(console.error);
237237
After:
238238
```javascript
239239
const consumer = kafka.consumer({
240-
kafkaJs: {
240+
kafkaJS: {
241241
groupId: 'test-group',
242242
fromBeginning: true,
243243
}
@@ -266,9 +266,9 @@ producerRun().then(consumerRun).catch(console.error);
266266
```
267267
After:
268268
```javascript
269-
const kafka = new Kafka({ kafkaJs: { /* ... */ } });
269+
const kafka = new Kafka({ kafkaJS: { /* ... */ } });
270270
const consumer = kafka.consumer({
271-
kafkaJs: {
271+
kafkaJS: {
272272
/* ... */,
273273
autoCommit: true,
274274
autoCommitInterval: 5000,

examples/kafkajs/admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Kafka } = require('../..').KafkaJS
33

44
async function adminStart() {
55
const kafka = new Kafka({
6-
kafkaJs: {
6+
kafkaJS: {
77
brokers: ['localhost:9092'],
88
}
99
});

examples/kafkajs/consumer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async function consumerStart() {
66
var stopped = false;
77

88
const kafka = new Kafka({
9-
kafkaJs: {
9+
kafkaJS: {
1010
brokers: ['localhost:9092'],
1111
ssl: true,
1212
connectionTimeout: 5000,
@@ -19,7 +19,7 @@ async function consumerStart() {
1919
});
2020

2121
consumer = kafka.consumer({
22-
kafkaJs: {
22+
kafkaJS: {
2323
groupId: 'test-group',
2424
autoCommit: false,
2525
rebalanceListener: {

examples/kafkajs/eos.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Kafka } = require('../..').KafkaJS
33

44
async function eosStart() {
55
const kafka = new Kafka({
6-
kafkaJs: {
6+
kafkaJS: {
77
brokers: ['<fill>'],
88
ssl: true,
99
sasl: {
@@ -15,14 +15,14 @@ async function eosStart() {
1515
});
1616

1717
const consumer = kafka.consumer({
18-
kafkaJs: {
18+
kafkaJS: {
1919
groupId: 'groupId',
2020
autoCommit: false,
2121
}
2222
});
2323

2424
const producer = kafka.producer({
25-
kafkaJs: {
25+
kafkaJS: {
2626
transactionalId: 'txid'
2727
}
2828
});

examples/kafkajs/producer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Kafka } = require('../..').KafkaJS
33

44
async function producerStart() {
55
const kafka = new Kafka({
6-
kafkaJs: {
6+
kafkaJS: {
77
brokers: ['<fill>'],
88
ssl: true,
99
sasl: {

lib/kafkajs/_admin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Admin {
7979
}
8080

8181
#finalizedConfig() {
82-
let compatibleConfig = this.#kafkaJSToAdminConfig(this.#userConfig.kafkaJs);
82+
let compatibleConfig = this.#kafkaJSToAdminConfig(this.#userConfig.kafkaJS);
8383

8484
/* Set the logger's level in case we're not in compatibility mode - just set it to DEBUG, the broadest
8585
* log level, as librdkafka will control the granularity. */
@@ -90,7 +90,7 @@ class Admin {
9090
let rdKafkaConfig = Object.assign(compatibleConfig, this.#userConfig);
9191

9292
/* Delete properties which are already processed, or cannot be passed to node-rdkafka */
93-
delete rdKafkaConfig.kafkaJs;
93+
delete rdKafkaConfig.kafkaJS;
9494

9595
return rdKafkaConfig;
9696
}

0 commit comments

Comments
 (0)