This repository has been archived by the owner on Jun 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.js
64 lines (59 loc) · 1.75 KB
/
config.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
const debug = require("debug");
const logger = {
debug: debug("kafka-rest:debug"),
info: debug("kafka-rest:info"),
warn: debug("kafka-rest:warn"),
error: debug("kafka-rest:error")
};
const host = "kafka";
const zhost = "zookeeper";
const config = {
logger,
consumer: {
autoremove: 30000,
noptions: {
//"debug": "all",
"metadata.broker.list": `${host}:9092`,
"group.id": "kafka-rest-group-test",
"event_cb": true,
"compression.codec": "none",
"enable.auto.commit": false
},
tconf: {
}
},
producer: {
noptions: {
//"debug": "all",
"metadata.broker.list": `${host}:9092`,
"client.id": "kafka-rest-client-test",
"event_cb": true,
"compression.codec": "none",
},
tconf: {
}
},
http:{
port: 8082
},
zookeeper: {
host: `${zhost}:2181`,
timeout: 20000
}
};
Object.keys(process.env).forEach((env)=>{
if(env === "KAFKA_REST_HTTP_PORT"){
config.http.port = process.env.KAFKA_REST_HTTP_PORT;
} else if(env.startsWith("KAFKA_REST_CONSUMER_")){
config.consumer.noptions[env.slice(20).toLowerCase().replace(/_/g, ".")] = process.env[env];
} else if(env.startsWith("KAFKA_REST_PRODUCER_")){
config.producer.noptions[env.slice(20).toLowerCase().replace(/_/g, ".")] = process.env[env];
} else if(env.startsWith("KAFKA_REST_ZOOKEEPER_")){
config.zookeeper[env.slice(21).toLowerCase().replace(/_/g, ".")] = process.env[env];
} else if(env.startsWith("KAFKA_REST_") && !env.startsWith("KAFKA_REST_UI_")){
config.consumer.noptions[env.slice(11).toLowerCase().replace(/_/g, ".")] = process.env[env];
config.producer.noptions[env.slice(11).toLowerCase().replace(/_/g, ".")] = process.env[env];
}
});
module.exports= config;