forked from senecajs/seneca-mesh
-
Notifications
You must be signed in to change notification settings - Fork 1
/
foo.js
35 lines (32 loc) · 803 Bytes
/
foo.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
// To run:
// $ node service-foo.js
var HOST = process.env.HOST || process.argv[2]
var BASES = (process.env.BASES || process.argv[3] || '').split(',')
var BROADCAST = process.env.BROADCAST
var REGISTRY = JSON.parse(process.env.REGISTRY || '{"active":false}')
require('seneca')({ tag: 'foo' })
.add('foo:1', function(msg, done) {
done(null, { x: 1, v: 100 + msg.v })
})
.use('consul-registry', REGISTRY || {})
.use('..', {
pin: 'foo:1',
host: HOST,
bases: BASES,
discover: {
multicast: {
address: BROADCAST
},
registry: REGISTRY
},
dumpnet: false,
sneeze: {
silent: false
}
})
.ready(function() {
var seneca = this
setInterval(function() {
seneca.act('bar:1,v:2,default$:{}', console.log)
}, 3000)
})