-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.js
82 lines (78 loc) · 1.61 KB
/
service.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
const seneca = require('seneca');
let start;
const status = seneca()
.use('mesh', {
pin: {
role: 'status'
},
discover: {
defined: {
active: false
},
custom: {
active: false
},
registry: {
active: false
},
multicast: {
active: true
},
guess: {
active: false
}
}
})
.add({
role: 'status',
cmd: 'ping'
}, (msg, reply) => {
reply(null, {
ping: 'pong1'
});
})
.add({
role: 'status',
cmd: 'time'
}, (msg, reply) => {
const ms = new Date() - start;
reply(null, {
time: ms
});
})
.ready(() => {
start = new Date();
console.log('Service `status` is ready to serve.');
});
const hello = seneca()
.use('mesh', {
listen: [
{ pin: 'role:hello' }
],
discover: {
defined: {
active: false
},
custom: {
active: false
},
registry: {
active: false
},
multicast: {
active: false
},
guess: {
active: false
}
}
})
.add({
role: 'hello'
}, (msg, reply) => {
reply(null, {
msg: 'ehllo'
});
})
.ready(() => console.log('Service `hello` is ready to serve.'));