Created
January 28, 2018 07:12
-
-
Save BransonGitomeh/783b156ed96b7a2e9ae214f90d4fa656 to your computer and use it in GitHub Desktop.
seneca microservices and clients talking to each other in a mesh fassion,
This file contains hidden or 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
| var seneca = require('seneca') | |
| seneca() | |
| // send matching actions out over the network | |
| .client({ | |
| host: "localhost", | |
| type: 'tcp', | |
| port: 10000, | |
| pin: 'color:blue' | |
| }) | |
| .client({ | |
| host: "localhost", | |
| type: 'tcp', | |
| port: 20000, | |
| pin: 'color:red' | |
| }) | |
| .act('color:red') | |
| .act('color:blue') |
This file contains hidden or 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
| { | |
| "dependencies": { | |
| "seneca": "^3.4.3" | |
| }, | |
| "scripts": { | |
| "start": "node client.js & node app2.js & node app1.js" | |
| } | |
| } |
This file contains hidden or 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
| function color() { | |
| this.add('color:red', function (args, done) { | |
| console.log("acting red") | |
| done(null, { | |
| hex: '#red' | |
| }); | |
| }) | |
| } | |
| var seneca = require('seneca') | |
| seneca() | |
| .use(color) | |
| .listen({ | |
| type: 'tcp', | |
| port: "20000" | |
| }) |
This file contains hidden or 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
| function color() { | |
| this.add('color:blue', function (args, done) { | |
| console.log("acting blue") | |
| done(null, { | |
| hex: 'blue' | |
| }); | |
| }) | |
| } | |
| var seneca = require('seneca') | |
| seneca() | |
| .use(color) | |
| .listen({ | |
| type: 'tcp', | |
| port: "10000" | |
| }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
todo: use redis for the transport rather than having to mention ports to connect to, broadcast the messages on redis and let the pattern matching in seneca find the correct services, that way its easier to add new services, and to use docker t deploy.