Authored by 黄涛

add path

Showing 1 changed file with 5 additions and 1 deletions
... ... @@ -15,6 +15,8 @@ const request = require('request');
* measurement:'api-duration'
* duration:2000 //ms per 200 send message,
* records:100 //when message over 100 send them
* immediate: true // send message immediate not wart records count if true
* path: "/url", // set target path default is /write
* }
*/
... ... @@ -26,6 +28,8 @@ class Sender extends EventEmitter {
this.options = options;
this.options.duration = this.options.duration || 2000;
this.options.records = this.options.records || 100;
this.options.path = this.options.path || '/write';
this.options.port = this.options.port || 80;
if (!this.options.db || !this.options.host) {
console.error('config error: db or host undefined!');
... ... @@ -131,7 +135,7 @@ class Sender extends EventEmitter {
headers: {
'content-type': 'text/plain'
},
url: `http://${this.options.host}:${this.options.port || 80}/write`,
url: `http://${this.options.host}:${this.options.port}${this.options.path}`,
qs: {
db: this.options.db
},
... ...