Created
July 25, 2017 19:01
-
-
Save KeKs0r/ba800af343c4f28e96f004b7b51c50e2 to your computer and use it in GitHub Desktop.
HemeraTestSuite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Hemera = require('nats-hemera') | |
const HemeraTestsuite = require('hemera-testsuite') | |
const PORT = 6242 | |
let server | |
server = HemeraTestsuite.start_server(PORT, {}, (err, res) => { | |
const nats = require('nats').connect(PORT) | |
const hemera = new Hemera(nats) | |
hemera.ready(() => { | |
hemera.add({ | |
topic: 'math', | |
cmd: 'add' | |
}, function (resp, cb) { | |
cb(null, resp.a + resp.b) | |
}) | |
hemera.act({ | |
topic: 'math', | |
cmd: 'add', | |
a: 1, | |
b: 2 | |
}, (err, resp) => { | |
if (err) console.error(err) | |
console.log(resp) | |
hemera.close() | |
server.kill() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment