-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.js
More file actions
29 lines (24 loc) · 768 Bytes
/
Copy pathadmin.js
File metadata and controls
29 lines (24 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// admin will create and manage topics
const { kafka } = require('./client');
async function init() {
// -------- connecting admin --------------
const admin = kafka.admin();
console.log('Connecting admin...');
admin.connect();
console.log('admin connecting success...');
// ------ topics -----------
console.log('Creating topic [rider-updates]')
await admin.createTopics({
topics: [
{
topic: 'rider-updates', // name of the topic
numPartitions: 2, // number of partitions
}
]
});
console.log('Topic created successfully [rider-updates]')
console.log('Disconnecting admin...')
// disconnect the admin
await admin.disconnect();
}
init()