Skip to content

Commit 41dae04

Browse files
authored
Merge pull request #53 from shikshalokam/master
remove ES
2 parents f7eb9d6 + 24e8eed commit 41dae04

File tree

10 files changed

+422
-469
lines changed

10 files changed

+422
-469
lines changed

.env.sample

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ INCOMPLETE_SURVEY_SUBMISSION_TOPIC = "dev.sl.incomplete.survey.raw"
1818
KAFKA_GROUP_ID = "survey" // Kafka consumer group for ML Survey Service
1919
IMPROVEMENT_PROJECT_SUBMISSION_TOPIC = "dev.sl.improvement.project.submission" // Kafka topic name for pushing project submission related data
2020

21-
# Elastic search configurations
22-
ELASTICSEARCH_COMMUNICATIONS_ON_OFF = "ON" // Elastic search enable/disable flag E.g. ON/OFF
23-
ELASTICSEARCH_HOST_URL = "http://127.0.0.1:9200" // Elastic search host url
24-
ELASTIC_SEARCH_SNIFF_ON_START = true/false // Flag to obtain ES Nodes list at the time of connection e.g. true/false
25-
ELASTICSEARCH_ENTITIES_INDEX = "entities" // Elastic search index name for storing entity data
2621

2722
# ML Core Service
2823
ML_CORE_SERVICE_URL = "http://ml-core-service:3000" // ML Core Service URL

config/db/elasticSearch.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@
77

88

99
//dependencies
10-
const { Client : esClient } = require('@elastic/elasticsearch');
11-
12-
/**
13-
* Elastic search connection.
14-
* @function
15-
* @name connect
16-
* @return {Object} elastic search client
17-
*/
18-
19-
var connect = function () {
20-
21-
const elasticSearchClient = new esClient({
22-
node : process.env.ELASTICSEARCH_HOST_URL,
23-
maxRetries : 5,
24-
requestTimeout : 60000,
25-
sniffOnStart : process.env.ELASTIC_SEARCH_SNIFF_ON_START
26-
});
27-
28-
elasticSearchClient.ping({
29-
}, function (error) {
30-
if (error) {
31-
console.log('Elasticsearch cluster is down!');
32-
} else {
33-
console.log('Elasticsearch connection established.');
34-
}
35-
});
36-
37-
return {
38-
client : elasticSearchClient
39-
};
40-
41-
};
42-
43-
module.exports = connect;
10+
// const { Client : esClient } = require('@elastic/elasticsearch');
11+
12+
// /**
13+
// * Elastic search connection.
14+
// * @function
15+
// * @name connect
16+
// * @return {Object} elastic search client
17+
// */
18+
19+
// var connect = function () {
20+
21+
// const elasticSearchClient = new esClient({
22+
// node : process.env.ELASTICSEARCH_HOST_URL,
23+
// maxRetries : 5,
24+
// requestTimeout : 60000,
25+
// sniffOnStart : process.env.ELASTIC_SEARCH_SNIFF_ON_START
26+
// });
27+
28+
// elasticSearchClient.ping({
29+
// }, function (error) {
30+
// if (error) {
31+
// console.log('Elasticsearch cluster is down!');
32+
// } else {
33+
// console.log('Elasticsearch connection established.');
34+
// }
35+
// });
36+
37+
// return {
38+
// client : elasticSearchClient
39+
// };
40+
41+
// };
42+
43+
// module.exports = connect;

config/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ let db_connect = function() {
2626
* @name elasticsearch_connect
2727
*/
2828

29-
let elasticsearch_connect = function () {
30-
global.elasticsearch = require("./db/elasticSearch")();
31-
};
29+
// let elasticsearch_connect = function () {
30+
// global.elasticsearch = require("./db/elasticSearch")();
31+
// };
3232

3333
/**
3434
* Kafka connection information.
@@ -49,6 +49,6 @@ const configuration = {
4949

5050
db_connect();
5151
kafka_connect();
52-
elasticsearch_connect();
52+
// elasticsearch_connect();
5353

5454
module.exports = configuration;

envVariables.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ let enviromentVariables = {
5858
"message" : "OFF/TOPIC_NAME",
5959
"optional" : false
6060
},
61-
"ELASTICSEARCH_COMMUNICATIONS_ON_OFF" : {
62-
"message" : "Enable/Disable elastic search communications",
63-
"optional" : false
64-
},
65-
"ELASTICSEARCH_HOST_URL" : {
66-
"message" : "Required elastic search host",
67-
"optional" : false
68-
},
69-
"ELASTICSEARCH_ENTITIES_INDEX" : {
70-
"message" : "Required entities index",
71-
"optional" : false
72-
},
61+
// "ELASTICSEARCH_COMMUNICATIONS_ON_OFF" : {
62+
// "message" : "Enable/Disable elastic search communications",
63+
// "optional" : false
64+
// },
65+
// "ELASTICSEARCH_HOST_URL" : {
66+
// "message" : "Required elastic search host",
67+
// "optional" : false
68+
// },
69+
// "ELASTICSEARCH_ENTITIES_INDEX" : {
70+
// "message" : "Required entities index",
71+
// "optional" : false
72+
// },
7373
"ML_CORE_SERVICE_URL" : {
7474
"message" : "Required core service url",
7575
"optional" : false
@@ -82,10 +82,10 @@ let enviromentVariables = {
8282
"message" : "Required keycloak public key path",
8383
"optional" : false
8484
},
85-
"ELASTIC_SEARCH_SNIFF_ON_START" : {
86-
"message" : "Elastic search sniff on start",
87-
"optional" : false
88-
},
85+
// "ELASTIC_SEARCH_SNIFF_ON_START" : {
86+
// "message" : "Elastic search sniff on start",
87+
// "optional" : false
88+
// },
8989
"DISABLE_LEARNER_SERVICE_ON_OFF": {
9090
"message" : "Disable learner service on/off",
9191
"default": "ON"

generics/helpers/elasticSearch.js

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
1-
/**
2-
* name : elasticSearch.js
3-
* author : Aman Jung Karki
4-
* created-date : 11-Jun-2020
5-
* Description : elastic search common functionality
6-
*/
7-
8-
/**
9-
* Get user data
10-
* @function
11-
* @name get
12-
* @param {String} id - a unique document id
13-
* @param {String} index - elastic search index
14-
* @param {String} type - elastic search type
15-
* @returns {Object} Get user data.
16-
*/
17-
18-
var get = function (
19-
id = "",
20-
index = "",
21-
type = ""
22-
) {
23-
24-
return new Promise(async function (resolve, reject) {
25-
try {
26-
27-
if (id == "") {
28-
throw new Error("ID is required");
29-
}
30-
31-
if (index == "") {
32-
throw new Error("Index is required");
33-
}
34-
35-
const result = await elasticsearch.client.get({
36-
id: id,
37-
index: index
38-
}, {
39-
ignore: [httpStatusCode["not_found"].status],
40-
maxRetries: 3
41-
});
42-
43-
return resolve(result);
44-
45-
} catch (error) {
46-
return reject(error);
47-
}
48-
})
49-
};
50-
51-
/**
52-
* Create or update based on user data.
53-
* @function
54-
* @name createOrUpdate
55-
* @param {String} id - a unique document id
56-
* @param {String} index - elastic search index
57-
* @param {String} data - requested data
58-
* @returns {Object} created or updated user data.
59-
*/
60-
61-
var createOrUpdate = function (
62-
id = "",
63-
index = "",
64-
data = ""
65-
) {
66-
67-
return new Promise(async function (resolve, reject) {
68-
try {
69-
70-
if (id == "") {
71-
throw new Error("ID is required");
72-
}
73-
74-
if (index == "") {
75-
throw new Error("Index is required");
76-
}
77-
78-
if (Object.keys(data).length == 0) {
79-
throw new Error("Data is required");
80-
}
81-
82-
let result =
83-
await elasticsearch.client.update({
84-
id : id,
85-
index : index,
86-
body : {
87-
doc : data ,
88-
doc_as_upsert : true
89-
}
90-
});
91-
92-
return resolve(result);
93-
94-
} catch (error) {
95-
return reject(error);
96-
}
97-
})
98-
};
99-
100-
module.exports = {
101-
get : get,
102-
createOrUpdate : createOrUpdate
103-
};
1+
// /**
2+
// * name : elasticSearch.js
3+
// * author : Aman Jung Karki
4+
// * created-date : 11-Jun-2020
5+
// * Description : elastic search common functionality
6+
// */
7+
8+
// /**
9+
// * Get user data
10+
// * @function
11+
// * @name get
12+
// * @param {String} id - a unique document id
13+
// * @param {String} index - elastic search index
14+
// * @param {String} type - elastic search type
15+
// * @returns {Object} Get user data.
16+
// */
17+
18+
// var get = function (
19+
// id = "",
20+
// index = "",
21+
// type = ""
22+
// ) {
23+
24+
// return new Promise(async function (resolve, reject) {
25+
// try {
26+
27+
// if (id == "") {
28+
// throw new Error("ID is required");
29+
// }
30+
31+
// if (index == "") {
32+
// throw new Error("Index is required");
33+
// }
34+
35+
// const result = await elasticsearch.client.get({
36+
// id: id,
37+
// index: index
38+
// }, {
39+
// ignore: [httpStatusCode["not_found"].status],
40+
// maxRetries: 3
41+
// });
42+
43+
// return resolve(result);
44+
45+
// } catch (error) {
46+
// return reject(error);
47+
// }
48+
// })
49+
// };
50+
51+
// *
52+
// * Create or update based on user data.
53+
// * @function
54+
// * @name createOrUpdate
55+
// * @param {String} id - a unique document id
56+
// * @param {String} index - elastic search index
57+
// * @param {String} data - requested data
58+
// * @returns {Object} created or updated user data.
59+
60+
61+
// var createOrUpdate = function (
62+
// id = "",
63+
// index = "",
64+
// data = ""
65+
// ) {
66+
67+
// return new Promise(async function (resolve, reject) {
68+
// try {
69+
70+
// if (id == "") {
71+
// throw new Error("ID is required");
72+
// }
73+
74+
// if (index == "") {
75+
// throw new Error("Index is required");
76+
// }
77+
78+
// if (Object.keys(data).length == 0) {
79+
// throw new Error("Data is required");
80+
// }
81+
82+
// let result =
83+
// await elasticsearch.client.update({
84+
// id : id,
85+
// index : index,
86+
// body : {
87+
// doc : data ,
88+
// doc_as_upsert : true
89+
// }
90+
// });
91+
92+
// return resolve(result);
93+
94+
// } catch (error) {
95+
// return reject(error);
96+
// }
97+
// })
98+
// };
99+
100+
// module.exports = {
101+
// get : get,
102+
// createOrUpdate : createOrUpdate
103+
// };

healthCheck/elastic-search.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +0,0 @@
1-
/**
2-
* name : elastic-search.js.
3-
* author : Aman Karki.
4-
* created-date : 02-Feb-2021.
5-
* Description : Elastic Search health check.
6-
*/
7-
8-
// Dependencies
9-
10-
const { Client : esClient } = require('@elastic/elasticsearch');
11-
12-
function health_check() {
13-
return new Promise( async (resolve,reject) => {
14-
15-
const elasticSearchClient = new esClient({
16-
node: process.env.ELASTICSEARCH_HOST_URL
17-
});
18-
19-
elasticSearchClient.ping({
20-
}, function (error) {
21-
if (error) {
22-
return resolve(false);
23-
} else {
24-
return resolve(true);
25-
}
26-
});
27-
})
28-
}
29-
30-
module.exports = {
31-
health_check : health_check
32-
}

0 commit comments

Comments
 (0)