-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.js
39 lines (35 loc) · 1.06 KB
/
worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const async = require('async')
const axios = require('axios')
const uid = "12345678"
const endpoint = process.env.ENDPOINT
const totalCall = 180000;
const concurrency = 3000;
let errCount = 0;
let successCount = 0;
let counting = []
for (let i = 0; i < totalCall; i++) {
counting.push(i)
}
(async () => {
let createProfileEndpoint = `${endpoint}/createProfile`
let resp = await axios.post(createProfileEndpoint, { uid })
console.log(resp)
let transactionEndpoint = `${endpoint}/testTransaction`
async.eachLimit(counting, concurrency, function (count, callback) {
console.log(`call ${count}`)
axios.post(transactionEndpoint, { uid }).then(function (resp) {
console.log(`success ${count}`)
successCount++;
callback()
}).catch(function (e) {
console.log(`fail ${count}`)
console.log(e)
errCount++;
callback()
})
}, function (e) {
console.log(e)
console.log("finished")
console.log({ successCount, errCount })
})
})();