-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from jembi/PLAT-346-kafak-topic-partitioning
Plat 346 kafka topic partitioning
- Loading branch information
Showing
10 changed files
with
137 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.9' | ||
|
||
services: | ||
await-helper: | ||
image: jembi/await-helper:1.0.1 | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: none | ||
command: '-k http://kafdrop:9013' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '3.9' | ||
|
||
services: | ||
message-bus-kafka-config-importer: | ||
image: jembi/instantohie-config-importer | ||
deploy: | ||
restart_policy: | ||
condition: none | ||
environment: | ||
KAFDROP_HOST: kafdrop | ||
KAFDROP_PORT: 9013 | ||
KAFKA_PARTITIONS: ${KAFKA_PARTITIONS:-3} | ||
KAFKA_TOPICS: ${KAFKA_TOPICS} | ||
command: sh -c "wait-on -t 60000 http-get://kafdrop:9013/topic && node /kafka.js && echo 'success';" | ||
configs: | ||
- source: kafka.js | ||
target: /kafka.js | ||
|
||
configs: | ||
kafka.js: | ||
file: ./kafka.js | ||
name: kafka-config.js-${kafka_config_DIGEST:?err} | ||
labels: | ||
name: ethiopia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
|
||
const http = require('http') | ||
|
||
const KAFDROP_HOST = process.env.KAFDROP_HOST || 'kafdrop' | ||
const KAFDROP_PORT = process.env.KAFDROP_PORT || '9013' | ||
const KAFKA_PARTITIONS = process.env.KAFKA_PARTITIONS || 3 | ||
const KAFKA_TOPICS= process.env.KAFKA_TOPICS | ||
|
||
const createKafkaTopic = topic => { | ||
const options = { | ||
protocol: 'http:', | ||
hostname: KAFDROP_HOST, | ||
path: '/topic', | ||
port: KAFDROP_PORT, | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
} | ||
|
||
const req = http.request(options, res => { | ||
if (res.statusCode != 200) { | ||
throw Error(`Failed to create topic - ${topic}`) | ||
} | ||
console.log(`Created topic - ${topic}`) | ||
}) | ||
req.write(`name=${topic}&partitionsNumber=${KAFKA_PARTITIONS}&replicationFactor=1`) | ||
req.end() | ||
} | ||
|
||
console.log('Creating kafka topics......................'); | ||
|
||
(() => { | ||
if (KAFKA_TOPICS) { | ||
KAFKA_TOPICS.split(',').forEach(topic => createKafkaTopic(topic)) | ||
} else { | ||
console.log('Topics not created: KAFKA_TOPICS variable invalid') | ||
process.exit(1) | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters