-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4f5aa1d
Showing
6 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/samples |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
Copyright (C) 2013, Angel J Lopez | ||
http://www.ajlopez.com | ||
http://ajlopez.wordpress.com | ||
http://twitter.com/ajlopez | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# MultiNodes | ||
|
||
Running many logical nodes in different machines, to build a distributed node cluster. Each logical node can host services, and interchange messages. | ||
|
||
## Description | ||
|
||
In some of my projects, I need to run services/applications that interchange message with other running processes. | ||
Instead of having each process open its own TCP/IP port and connecting to the other processes that host the | ||
same service/application, I want to have an utility to manage such cases. MultiNodes does: | ||
|
||
- Start a logical node in a worker process. | ||
- Expose the logical node to other nodes in the node set. | ||
- Connect to other logical nodes. | ||
- Declare and exposes the local services/applications. | ||
- Exchange messages (simple JavaScript objects serializable to JSON) between distributed services/applications. | ||
|
||
See a logical node as an object running in a machine, using Node.js. | ||
|
||
See a service/application as an object that sends and receives messages. | ||
|
||
Related projects that need this functionality: | ||
|
||
- [SimpleStorm](https://github.com/ajlopez/SimpleStorm) Simple Storm-like distributed application implementation. | ||
- [AjFabriqNode](https://github.com/ajlopez/AjFabriqNode) A Distributed Application Framework for NodeJs. | ||
|
||
Example: [SimpleStorm](https://github.com/ajlopez/SimpleStorm) can run local topologies, | ||
like the original [Storm Java project](http://storm-project.net/). | ||
But it can run distributed topologies, too. Each task in those | ||
topologies can emit message to the other tasks, that can be local or remote. Instead of managing by itself | ||
the connection and discovery of the other remote machines running topologies, SimpleStorm could rely on | ||
MultiNode to manage the distributed logical nodes. | ||
|
||
## Installation | ||
|
||
Via npm on Node: | ||
|
||
``` | ||
npm install multinodes | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
Reference in your program: | ||
|
||
```js | ||
var multinodes = require('multinodes'); | ||
``` | ||
|
||
TBD | ||
## Development | ||
|
||
``` | ||
git clone git://github.com/ajlopez/MultiNodes.git | ||
cd MultiNodes | ||
npm install | ||
npm test | ||
``` | ||
|
||
## Samples | ||
|
||
TBD | ||
|
||
## To do | ||
|
||
- Samples | ||
|
||
## Contribution | ||
|
||
Feel free to [file issues](https://github.com/ajlopez/MultiNodes) and submit | ||
[pull requests](https://github.com/ajlopez/MultiNodes/pulls) — contributions are | ||
welcome. | ||
|
||
If you submit a pull request, please be sure to add or update corresponding | ||
test cases, and ensure that `npm test` continues to pass. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ "name": "multinodes" | ||
, "description": "Running many logical nodes in different machines. Each logical node can host services, and interchange messages." | ||
, "keywords": [ "node.js", "distributed", "application", "application" ] | ||
, "version": "0.0.1alpha" | ||
, "author": "Angel 'Java' Lopez <webmaster@ajlopez.com> (http://www.ajlopez.com)" | ||
, "repository": { "type": "git", "url": "git://github.com/ajlopez/MultiNodes.git" } | ||
, "main": "./lib/multinodes.js" | ||
, "engines": { "node": ">= 0.6.0 && < 0.9.0" } | ||
, "scripts": { | ||
"test": "node ./test.js" | ||
} | ||
, "dependencies": { | ||
} | ||
, "devDependencies": { | ||
"nodeunit": ">= 0.7.4" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env node | ||
|
||
// Based on https://github.com/laverdet/node-fibers/blob/master/test.js | ||
|
||
var fs = require('fs'); | ||
var spawn = require('child_process').spawn; | ||
var path = require('path'); | ||
|
||
function runTest(test, cb) { | ||
var proc = spawn(process.execPath, [path.join('test', test)], {env: {NODE_PATH: __dirname}}); | ||
proc.stdout.setEncoding('utf8'); | ||
proc.stderr.setEncoding('utf8'); | ||
|
||
var stdout = '', stderr = ''; | ||
proc.stdout.on('data', function(data) { | ||
stdout += data; | ||
}); | ||
proc.stderr.on('data', function(data) { | ||
stderr += data; | ||
}); | ||
proc.stdin.end(); | ||
|
||
proc.on('exit', function(code) { | ||
if ((stdout !== 'pass\n' && stdout !== '') || stderr !== '') { | ||
return cb(new Error( | ||
'Test `'+ test+ '` failed.\n'+ | ||
'code: '+ code+ '\n'+ | ||
'stderr: '+ stderr+ '\n'+ | ||
'stdout: '+ stdout)); | ||
} | ||
console.log(test+ ': '+ 'pass'); | ||
cb(); | ||
}); | ||
} | ||
|
||
var cb = function(err) { | ||
if (err) { | ||
console.error(String(err)); | ||
process.exit(1); | ||
} | ||
}; | ||
fs.readdirSync('./test').reverse().forEach(function(file) { | ||
var stats = fs.lstatSync(path.join('./test',file)); | ||
if (!stats.isFile()) | ||
return; | ||
|
||
cb = new function(cb, file) { | ||
return function(err) { | ||
if (err) return cb(err); | ||
runTest(file, cb); | ||
}; | ||
}(cb, file); | ||
}); | ||
cb(); |