-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.js
49 lines (43 loc) · 1.26 KB
/
load.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
40
41
42
43
44
45
46
47
48
49
var http = require('http');
var request = require('request');
var randomstring = require('randomstring');
var infiniteLoop = require('infinite-loop');
var console = require('console');
var guid = require('guid');
var id = 0;
var makeCandidate = function(instanceId){
return {
firstName: randomstring.generate({
charset: 'alphabetic',
length: 6
}),
lastName: randomstring.generate({
charset: 'alphabetic',
length: 8
}),
instanceId: instanceId,
personId: (id++).toString()
};
};
var requestOptions = {
headers: {
"Content-Type": "application/vnd.eventstore.events+json"
},
};
var post = function(instanceId){
var candidateEvent = [ {
eventId: guid.create(),
eventType: 'personaldetails-updated',
data: makeCandidate(instanceId)
} ];
requestOptions.url = "http://192.168.98.100:2113/streams/candidate-" + instanceId + "-" + candidateEvent[0].data.personId;
requestOptions.body = JSON.stringify(candidateEvent);
request.post(requestOptions, function(err, response){
if(err) throw err;
console.log(response.statusCode + JSON.stringify(candidateEvent));
response.on('data', function(chunk){
console.log('response is ' + chunk);
});
});
};
new infiniteLoop().add(post, 218).run();