-
Notifications
You must be signed in to change notification settings - Fork 0
/
l2.js
62 lines (50 loc) · 1.17 KB
/
l2.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
50
51
52
53
54
55
56
57
58
59
60
61
62
const dns = require('dns');
function dnsSeed (seneca, options, bases, next) {
dns.lookup(
'test',
{
all: true,
family: 4
},
(err, addresses) => {
let bases = [];
if (err) {
throw new Error('dns lookup for base node failed');
}
if (Array.isArray(addresses)) {
bases = addresses.map((address) => {
return address.address;
});
} else {
bases.push(addresses);
}
next(bases);
}
);
}
const config = {
auto: true,
listen: [{ pin: 'service:user,command:*', model: 'consume', type: 'tcp' }],
discover: {
rediscover: true,
custom: {
active: true,
find: dnsSeed
}
}
}
config.bases = '127.0.0.1:39000,127.0.0.1:39001'.split(',');
let microwizard;
(async function() {
const { default: Microwizard, transport } = (await import("microwizard"));
microwizard = new Microwizard()
setTimeout(() => {
console.log('calling peter')
for(let i = 0; i< 5;++i) {
microwizard.act('service:peter,command:test', {hello: 123}).then(msg => {
console.log('hello', msg)
})
}
}, 1000)
microwizard.use('mesh', config)
})()