Skip to content

Commit 3902755

Browse files
cleanup KAFKA_TOPIC_IGNORE_PREFIX from code as we are now using CloudKarfka with same topic name for dev and prod.
1 parent a6a68ec commit 3902755

File tree

4 files changed

+4
-15
lines changed

4 files changed

+4
-15
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ The following parameters can be set in config files or in env variables:
2424
- `JWKS_URI`: TC auth JWKS URI (need only for local deployment)
2525
- **KAFKA**
2626
- `KAFKA_URL`: comma separated Kafka hosts
27-
- `KAFKA_TOPIC_IGNORE_PREFIX`: ignore this prefix for topics in the Kafka
2827
- `KAFKA_GROUP_ID`: Kafka consumer group id
2928
- `KAFKA_CLIENT_CERT`: Kafka connection certificate, optional;
3029
if not provided, then SSL connection is not used, direct insecure connection is used;
@@ -97,7 +96,6 @@ You may reuse it during review.
9796
- for local development environment you can set variables as following:
9897
- `AUTH_SECRET`,`VALID_ISSUERS` can get from [tc-project-service config](https://github.com/topcoder-platform/tc-project-service/blob/dev/config/default.json)
9998
- `PORT=4000` because **connect-app** call this port by default
100-
- `KAFKA_TOPIC_IGNORE_PREFIX=joan-26673.` (with point at the end)
10199
- `TC_API_V4_BASE_URL=https://api.topcoder-dev.com/v4`
102100
- `TC_API_V3_BASE_URL=https://api.topcoder-dev.com/v3`
103101
- `KAFKA_URL`, `KAFKA_CLIENT_CERT` and `KAFKA_CLIENT_CERT_KEY` get from [tc-bus-api readme](https://github.com/topcoder-platform/tc-bus-api/tree/dev)

config/default.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module.exports = {
2323
// which skips token validation when locally deployed
2424

2525
KAFKA_URL: process.env.KAFKA_URL,
26-
KAFKA_TOPIC_IGNORE_PREFIX: process.env.KAFKA_TOPIC_IGNORE_PREFIX,
2726
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID,
2827
KAFKA_CLIENT_CERT: process.env.KAFKA_CLIENT_CERT ? process.env.KAFKA_CLIENT_CERT.replace('\\n', '\n') : null,
2928
KAFKA_CLIENT_CERT_KEY: process.env.KAFKA_CLIENT_CERT_KEY ?

deploy.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ AWS_ECS_SERVICE=$(eval "echo \$${ENV}_AWS_ECS_SERVICE")
3434
KAFKA_CLIENT_CERT=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT")
3535
KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
3636
KAFKA_GROUP_ID=$(eval "echo \$${ENV}_KAFKA_GROUP_ID")
37-
KAFKA_TOPIC_IGNORE_PREFIX=$(eval "echo \$${ENV}_KAFKA_TOPIC_IGNORE_PREFIX")
3837
KAFKA_URL=$(eval "echo \$${ENV}_KAFKA_URL")
3938
AUTHSECRET=$(eval "echo \$${ENV}_AUTHSECRET")
4039
VALID_ISSUERS=$(eval "echo \$${ENV}_VALID_ISSUERS")
@@ -138,10 +137,6 @@ make_task_def(){
138137
"name": "KAFKA_GROUP_ID",
139138
"value": "%s"
140139
},
141-
{
142-
"name": "KAFKA_TOPIC_IGNORE_PREFIX",
143-
"value": "%s"
144-
},
145140
{
146141
"name": "KAFKA_URL",
147142
"value": "%s"
@@ -261,7 +256,7 @@ make_task_def(){
261256
}
262257
]'
263258

264-
task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID "$KAFKA_TOPIC_IGNORE_PREFIX" $KAFKA_URL $DATABASE_URL $AUTHSECRET $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $REPLY_EMAIL_FROM $DEFAULT_REPLY_EMAIL $ENABLE_DEV_MODE $DEV_MODE_EMAIL $LOG_LEVEL $VALID_ISSUERS $PORT "$API_CONTEXT_PATH" "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
259+
task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $DATABASE_URL $AUTHSECRET $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $REPLY_EMAIL_FROM $DEFAULT_REPLY_EMAIL $ENABLE_DEV_MODE $DEV_MODE_EMAIL $LOG_LEVEL $VALID_ISSUERS $PORT "$API_CONTEXT_PATH" "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
265260
}
266261

267262
register_definition() {

src/app.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ function startKafkaConsumer(handlers, notificationServiceHandlers) {
3434
const message = m.message.value.toString('utf8');
3535
logger.info(`Handle Kafka event message; Topic: ${topic}; Partition: ${partition}; Offset: ${
3636
m.offset}; Message: ${message}.`);
37-
// ignore configured Kafka topic prefix
37+
3838
let topicName = topic;
39-
if (config.KAFKA_TOPIC_IGNORE_PREFIX && topicName.startsWith(config.KAFKA_TOPIC_IGNORE_PREFIX)) {
40-
topicName = topicName.substring(config.KAFKA_TOPIC_IGNORE_PREFIX.length);
41-
}
39+
4240
// find handler
4341
const handler = handlers[topicName];
4442
if (!handler) {
@@ -75,8 +73,7 @@ function startKafkaConsumer(handlers, notificationServiceHandlers) {
7573
consumer
7674
.init()
7775
.then(() => _.each(_.keys(handlers),
78-
// add back the ignored topic prefix to use full topic name
79-
(topicName) => consumer.subscribe(`${config.KAFKA_TOPIC_IGNORE_PREFIX || ''}${topicName}`, dataHandler)))
76+
(topicName) => consumer.subscribe(topicName, dataHandler)))
8077
.catch((err) => logger.error(err));
8178
}
8279

0 commit comments

Comments
 (0)