Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics service Integration for ticker functionality and DB migration Script in Donor service #409

Merged
merged 16 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backend/donor-service/configs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const ESIGN_STATUS = Object.freeze({
const ESIGN_VALIDATION_KAFKA_BROKERS = process.env.ESIGN_VALIDATION_KAFKA_BROKERS || 'localhost:5101';
let ESIGN_VALIDATION_EXPIRE_TIME = process.env.ESIGN_VALIDATION_EXPIRE_TIME || 2*60;
const ESIGN_VALIDATION_PREVENT_3RD_PARTY = process.env.ESIGN_VALIDATION_PREVENT_3RD_PARTY === "true" || false;
const METRICS_URL = process.env.METRICS_URL || 'http://metrics:8070';
const KAFKA_BROKER_FOR_METRICS_SERVICE = process.env.KAFKA_BROKER_FOR_METRICS_SERVICE || 'kafka:9092';
const METRICS_TOPIC = process.env.METRICS_TOPIC || 'events';
const ESIGN_VALIDATION_KAFKA_TOPIC = process.env.ESIGN_VALIDATION_KAFKA_TOPIC || 'esign_topic';
const ESIGN_VALIDATION_KAFKA_TOPIC_GROUP = process.env.ESIGN_VALIDATION_KAFKA_TOPIC_GROUP || 'dev_esign_group_1';
const ESIGN_VALIDATION_CLIENT_ID = process.env.ESIGN_VALIDATION_CLIENT_ID || "dev-esign-client";
Expand Down Expand Up @@ -75,5 +78,8 @@ module.exports = {
ESIGN_VALIDATION_PREVENT_3RD_PARTY,
ESIGN_VALIDATION_KAFKA_TOPIC,
ESIGN_VALIDATION_KAFKA_TOPIC_GROUP,
ESIGN_VALIDATION_CLIENT_ID,
METRICS_URL,
KAFKA_BROKER_FOR_METRICS_SERVICE,
METRICS_TOPIC,
ESIGN_VALIDATION_CLIENT_ID
}
34 changes: 34 additions & 0 deletions backend/donor-service/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const {PLEDGE_STATUS, GENDER_MAP, SOCIAL_SHARE_TEMPLATE_MAP} = require('./config
const app = express();
const {convertToSocialShareResponse} = require("./utils/utils");
const consumer = require("./services/esign.consumer");
const metricsService = require('./services/metrics.service');
const dataMigrationScript = require('./utils/scriptForDataMigration');

(async() => {
await redis.initRedis({REDIS_URL: config.REDIS_URL});
Expand Down Expand Up @@ -749,4 +751,36 @@ app.use(function(err, req, res, next) {
message: "Internal server error"
})
});

// Metrics Sercvice Integration
app.get('/getMetrics/:schemaType', (req,res) => metricsService.getMetrics(req,res));


// Data Migration Script for NHA PROD
//
// pathParmas ---> entityName ex: /Pledge
// sample request body :
// {
// "osIdArray" : ["b6189f8f-9ef3-499f-961b-94bdd540f3cd"]
// }
app.post('/pushDataToCH/:entityName', async (req,res) => {
let entityName = req.params.entityName;
let osidArray = req.body.osIdArray;
console.log(osidArray, entityName);
let accessToken = await getServiceAccountToken();
try {
for (let i=0 ; i< osidArray.length; i++) {
await dataMigrationScript.migrateDataToCH(entityName,osidArray[i], accessToken);
await new Promise(resolve => setTimeout(resolve, 500)); // wait for 500 millisecons
}
res.status(200).send({
message: "Data Migaration Successfull!",
})
} catch (error) {
console.log("error while db migraiton",error);
res.status(500).send(error)
}

})

app.listen('3000');
Loading
Loading