Skip to content

Commit

Permalink
Renamed the producer fucntion and added a flag to enable and disable …
Browse files Browse the repository at this point in the history
…Metrics
  • Loading branch information
sreejith.k committed Sep 1, 2023
1 parent 7894b02 commit 44927db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/donor-service/services/kafka.producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const config = require('../configs/config');
const { Kafka, Partitioners } = require('kafkajs');

// Connect and send the event
async function produceEventToKafka(topic, telemetryEvent) {
async function emitEventToKafka(topic, telemetryEvent) {

const kafka = new Kafka({
clientId: 'dB-Migration',
Expand All @@ -26,6 +26,6 @@ const producer = kafka.producer();
}

module.exports = {
produceEventToKafka
emitEventToKafka
}

3 changes: 1 addition & 2 deletions backend/donor-service/utils/scriptForDataMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { default: axios } = require('axios');
const config = require('../configs/config');
const op = require('object-path');
const kafkaClient =require('../services/kafka.producer');
const { Kafka, Partitioners } = require('kafkajs');


const topicName = `${config.METRICS_TOPIC}`;
Expand All @@ -20,7 +19,7 @@ async function migrateDataToCH (entityName, entityId, accessToken) {
if (getTheDataFromRegistry.data && getTheDataFromRegistry.data != '') {
let transformedData = transformTheData(getTheDataFromRegistry.data, entityName);
let telemertryObject = getTelemtryObject( entityName , entityId,transformedData);
await kafkaClient.produceEventToKafka(topicName, telemertryObject)
await kafkaClient.emitEventToKafka(topicName, telemertryObject)
console.log("Migration was successfull!");
}
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ services:
- external_entities=nha-admin
- invite_required_validation_enabled=false
- invite_signature_enabled=false
- event_enabled=true
- event_enabled=${ENABLE_METRICS_SERVICE-false}
- event_topic=${METRICS_TOPIC-events}
- event_providerName=dev.sunbirdrc.registry.service.impl.KafkaEventService
ports:
Expand Down Expand Up @@ -374,5 +374,5 @@ services:
ESIGN_VALIDATION_KAFKA_TOPIC: ${ESIGN_VALIDATION_KAFKA_TOPIC}
ESIGN_VALIDATION_KAFKA_TOPIC_GROUP: ${ESIGN_VALIDATION_KAFKA_TOPIC_GROUP}
METRICS_URL: ${METRICS_URL}
KAFKA_BROKER: ${KAFKA_BROKER}
KAFKA_BROKER_FOR_METRICS_SERVICE: ${KAFKA_BROKER_FOR_METRICS_SERVICE}
METRICS_TOPIC: ${METRICS_TOPIC}

0 comments on commit 44927db

Please sign in to comment.