-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathexample-fauxgrenache.js
More file actions
44 lines (35 loc) · 1001 Bytes
/
example-fauxgrenache.js
File metadata and controls
44 lines (35 loc) · 1001 Bytes
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
'use strict'
const createGrapes = require('./grapes')
const createClient = require('./client')
const createFxGrenache = require('./fauxgrenache')
const grapes = createGrapes()
const stubs = {
'rest:util:net': {
getIpInfo (space, ip, cb) {
const res = [ip, { country: 'US', region: 'CA' }]
return cb(null, res)
}
}
}
;(async () => {
await grapes.start()
// lets create a worker stub
// we can pass in Grape instances or an url
const url = 'http://localhost:30001'
const grape = grapes || url
const fxg = createFxGrenache(stubs, grape)
await fxg.start()
console.log('stub service started, announcing on grape')
const client = createClient('rest:util:net')
const res = await client.request({
action: 'getIpInfo',
args: ['8.8.8.8']
})
console.log('got response:', res)
await client.stop()
console.log('client stopped')
await fxg.stop()
console.log('grenache stub stopped')
await grapes.stop()
console.log('grapes stopped')
})()