mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Merge pull request #180 from Godmave/master
add compression to research sync
This commit is contained in:
1 file changed
+13
-8
@@ -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)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user