Merge pull request #180 from Godmave/master

add compression to research sync
This commit is contained in:
Godmave authored and GitHub committed 2019-07-25 23:23:57 +02:00
commit e733cfde03
1 file changed
+13 -8
+13 -8
View File
@@ -52,7 +52,7 @@ class ResearchSync {
get_node_name_and_move_log() { get_node_name_and_move_log() {
const url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves` const url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves`
needle.get(url, (err, res, slaves_data) => { needle.get(url, {compressed:true}, (err, res, slaves_data) => {
if (err) if (err)
return this.error(err) return this.error(err)
@@ -82,7 +82,8 @@ class ResearchSync {
} }
const options = { const options = {
headers: {'x-access-token': this.config.masterAuthToken}, headers: {'x-access-token': this.config.masterAuthToken},
json: true json: true,
compressed: true
} }
needle.post(url, data, options, (err, res, techs) => { needle.post(url, data, options, (err, res, techs) => {
if (err) { if (err) {
@@ -103,10 +104,14 @@ class ResearchSync {
this.error(`status code ${res.statusCode}, ${res.body}`) this.error(`status code ${res.statusCode}, ${res.body}`)
return return
} }
techs = JSON.parse(techs) if(techs.toString()!="") {
if (typeof techs.research === 'object') techs = JSON.parse(techs)
this.research = techs.research if (typeof techs.research === 'object')
this.log('techs imported from master') this.research = techs.research
this.log('techs imported from master')
} else {
this.log('no techs imported from master, since there are none yet')
}
callback() callback()
}) })
} }
@@ -123,7 +128,7 @@ class ResearchSync {
request_cluster_data() { request_cluster_data() {
const slaves_data_url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves` const slaves_data_url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves`
needle.get(slaves_data_url, this.sync_researches.bind(this)) needle.get(slaves_data_url, this.sync_researches.bind(this), {compressed:true})
} }
sync_researches(err, resp, slaves_data) { sync_researches(err, resp, slaves_data) {
@@ -158,7 +163,7 @@ class ResearchSync {
instanceID: this.config.unique, instanceID: this.config.unique,
password: this.config.clientPassword, password: this.config.clientPassword,
meta: {research: this.research} meta: {research: this.research}
}, {headers: {'x-access-token': this.config.masterAuthToken}, json: true}, (err, resp) => { }, {headers: {'x-access-token': this.config.masterAuthToken}, json: true, compressed:true}, (err, resp) => {
if (err) if (err)
this.error(err) this.error(err)
}) })