feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
19
api.hyungi.net/node_modules/pm2-axon-rpc/History.md
generated
vendored
Normal file
19
api.hyungi.net/node_modules/pm2-axon-rpc/History.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
### 0.0.x
|
||||
|
||||
---
|
||||
|
||||
#### 0.0.3 — 2014-05-07
|
||||
|
||||
* Update to make axon-rpc compatible with axon 2.x.
|
||||
* Added the original error stack to the error received by the client.
|
||||
* Fixed tests on Windows.
|
||||
* Fixed crash on empty error message.
|
||||
|
||||
#### 0.0.2 — 2013-03-25
|
||||
|
||||
* bump axon version so we include the req/rep fixes
|
||||
|
||||
#### 0.0.1 — 2010-01-03
|
||||
|
||||
* Initial release
|
||||
6
api.hyungi.net/node_modules/pm2-axon-rpc/Makefile
generated
vendored
Normal file
6
api.hyungi.net/node_modules/pm2-axon-rpc/Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
||||
132
api.hyungi.net/node_modules/pm2-axon-rpc/Readme.md
generated
vendored
Normal file
132
api.hyungi.net/node_modules/pm2-axon-rpc/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
# axon-rpc
|
||||
|
||||
[](https://travis-ci.org/unitech/pm2-axon-rpc)
|
||||
|
||||
RPC client / server for [axon](https://github.com/visionmedia/axon).
|
||||
|
||||
## arpc(1)
|
||||
|
||||
The `arpc(1)` executable allows you to expose entire
|
||||
node modules with a single command, or inspect
|
||||
methods exposed by a given node.
|
||||
|
||||
```
|
||||
|
||||
Usage: arpc [options] <module>
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
-a, --addr <addr> bind to the given <addr>
|
||||
-m, --methods <addr> inspect methods exposed by <addr>
|
||||
|
||||
```
|
||||
|
||||
## Server
|
||||
|
||||
```js
|
||||
var rpc = require('axon-rpc')
|
||||
, axon = require('axon')
|
||||
, rep = axon.socket('rep');
|
||||
|
||||
var server = new rpc.Server(rep);
|
||||
rep.bind(4000);
|
||||
```
|
||||
|
||||
### Server#expose(name, fn)
|
||||
|
||||
Expose a single method `name` mapped to `fn` callback.
|
||||
|
||||
```js
|
||||
server.expose('add', function(a, b, fn){
|
||||
fn(null, a + b);
|
||||
});
|
||||
```
|
||||
|
||||
### Server#expose(object)
|
||||
|
||||
Expose several methods:
|
||||
|
||||
```js
|
||||
server.expose({
|
||||
add: function(){ ... },
|
||||
sub: function(){ ... }
|
||||
});
|
||||
```
|
||||
|
||||
This may also be used to expose
|
||||
an entire node module with exports:
|
||||
|
||||
```js
|
||||
server.expose(require('./api'));
|
||||
```
|
||||
|
||||
## Client
|
||||
|
||||
```js
|
||||
var rpc = require('axon-rpc')
|
||||
, axon = require('axon')
|
||||
, req = axon.socket('req');
|
||||
|
||||
var client = new rpc.Client(req);
|
||||
req.connect(4000);
|
||||
```
|
||||
|
||||
### Client#call(name, ..., fn)
|
||||
|
||||
Invoke method `name` with some arguments and invoke `fn(err, ...)`:
|
||||
|
||||
```js
|
||||
client.call('add', 1, 2, function(err, n){
|
||||
console.log(n);
|
||||
// => 3
|
||||
})
|
||||
```
|
||||
|
||||
### Client#methods(fn)
|
||||
|
||||
Request available methods:
|
||||
|
||||
```js
|
||||
client.methods(function(err, methods){
|
||||
console.log(methods);
|
||||
})
|
||||
```
|
||||
|
||||
Responds with objects such as:
|
||||
|
||||
```js
|
||||
{
|
||||
add: {
|
||||
name: 'add',
|
||||
params: ['a', 'b', 'fn']
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@learnboost.com>
|
||||
|
||||
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.
|
||||
16
api.hyungi.net/node_modules/pm2-axon-rpc/example.js
generated
vendored
Normal file
16
api.hyungi.net/node_modules/pm2-axon-rpc/example.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
exports.add = function(a, b, fn){
|
||||
fn(null, a + b);
|
||||
};
|
||||
|
||||
exports.sub = function(a, b, fn){
|
||||
fn(null, a - b);
|
||||
};
|
||||
|
||||
exports.uppercase = function(str, fn){
|
||||
fn(null, str.toUpperCase());
|
||||
};
|
||||
|
||||
exports.lowercase = function(str, fn){
|
||||
fn(null, str.toLowerCase());
|
||||
};
|
||||
3
api.hyungi.net/node_modules/pm2-axon-rpc/index.js
generated
vendored
Normal file
3
api.hyungi.net/node_modules/pm2-axon-rpc/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
exports.Server = require('./lib/server');
|
||||
exports.Client = require('./lib/client');
|
||||
63
api.hyungi.net/node_modules/pm2-axon-rpc/lib/client.js
generated
vendored
Normal file
63
api.hyungi.net/node_modules/pm2-axon-rpc/lib/client.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
/**
|
||||
* Expose `Client`.
|
||||
*/
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
/**
|
||||
* Initialize an rpc client with `sock`.
|
||||
*
|
||||
* @param {Socket} sock
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Client(sock) {
|
||||
if (typeof sock.format === 'function') sock.format('json');
|
||||
this.sock = sock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke method `name` with args and invoke the
|
||||
* tailing callback function.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Mixed} ...
|
||||
* @param {Function} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Client.prototype.call = function(name){
|
||||
var args = [].slice.call(arguments, 1, -1);
|
||||
var fn = arguments[arguments.length - 1];
|
||||
|
||||
this.sock.send({
|
||||
type: 'call',
|
||||
method: name,
|
||||
args: args
|
||||
}, function(msg){
|
||||
if ('error' in msg) {
|
||||
var err = new Error(msg.error);
|
||||
err.stack = msg.stack || err.stack;
|
||||
fn(err);
|
||||
} else {
|
||||
msg.args.unshift(null);
|
||||
fn.apply(null, msg.args);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch the methods exposed and invoke `fn(err, methods)`.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Client.prototype.methods = function(fn){
|
||||
this.sock.send({
|
||||
type: 'methods'
|
||||
}, function(msg){
|
||||
fn(null, msg.methods);
|
||||
});
|
||||
};
|
||||
139
api.hyungi.net/node_modules/pm2-axon-rpc/lib/server.js
generated
vendored
Normal file
139
api.hyungi.net/node_modules/pm2-axon-rpc/lib/server.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug');
|
||||
|
||||
/**
|
||||
* Expose `Server`.
|
||||
*/
|
||||
|
||||
module.exports = Server;
|
||||
|
||||
/**
|
||||
* Initialize a server with the given `sock`.
|
||||
*
|
||||
* @param {Socket} sock
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Server(sock) {
|
||||
if (typeof sock.format === 'function') sock.format('json');
|
||||
this.sock = sock;
|
||||
this.methods = {};
|
||||
this.sock.on('message', this.onmessage.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return method descriptions with:
|
||||
*
|
||||
* `.name` string
|
||||
* `.params` array
|
||||
*
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.methodDescriptions = function(){
|
||||
var obj = {};
|
||||
var fn;
|
||||
|
||||
for (var name in this.methods) {
|
||||
fn = this.methods[name];
|
||||
obj[name] = {
|
||||
name: name,
|
||||
params: params(fn)
|
||||
};
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Response with the method descriptions.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.respondWithMethods = function(reply){
|
||||
reply({ methods: this.methodDescriptions() });
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle `msg`.
|
||||
*
|
||||
* @param {Object} msg
|
||||
* @param {Object} fn
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Server.prototype.onmessage = function(msg, reply){
|
||||
if ('methods' == msg.type) return this.respondWithMethods(reply);
|
||||
|
||||
if (!reply) {
|
||||
console.error('reply false');
|
||||
return false;
|
||||
}
|
||||
|
||||
// .method
|
||||
var meth = msg.method;
|
||||
if (!meth) return reply({ error: '.method required' });
|
||||
|
||||
// ensure .method is exposed
|
||||
var fn = this.methods[meth];
|
||||
if (!fn) return reply({ error: 'method "' + meth + '" does not exist' });
|
||||
|
||||
// .args
|
||||
var args = msg.args;
|
||||
if (!args) return reply({ error: '.args required' });
|
||||
|
||||
// invoke
|
||||
args.push(function(err){
|
||||
if (err) {
|
||||
if (err instanceof Error)
|
||||
return reply({ error: err.message, stack: err.stack });
|
||||
else
|
||||
return reply({error : err});
|
||||
}
|
||||
var args = [].slice.call(arguments, 1);
|
||||
reply({ args: args });
|
||||
});
|
||||
|
||||
fn.apply(null, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose many or a single method.
|
||||
*
|
||||
* @param {String|Object} name
|
||||
* @param {String|Object} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Server.prototype.expose = function(name, fn){
|
||||
if (1 == arguments.length) {
|
||||
for (var key in name) {
|
||||
this.expose(key, name[key]);
|
||||
}
|
||||
} else {
|
||||
debug('expose "%s"', name);
|
||||
this.methods[name] = fn;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse params.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function params(fn) {
|
||||
// remove space to make it work on node 10.x.x too
|
||||
var ret = fn.toString().replace(/\s/g, '').match(/^function *(\w*)\((.*?)\)/)[2];
|
||||
if (ret) return ret.split(/ *, */);
|
||||
return [];
|
||||
}
|
||||
38
api.hyungi.net/node_modules/pm2-axon-rpc/package.json
generated
vendored
Normal file
38
api.hyungi.net/node_modules/pm2-axon-rpc/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "pm2-axon-rpc",
|
||||
"version": "0.7.1",
|
||||
"description": "Remote procedure calls built on top of axon.",
|
||||
"keywords": [
|
||||
"axon",
|
||||
"rpc",
|
||||
"cloud"
|
||||
],
|
||||
"author": "TJ Holowaychuk <tj@learnboost.com>",
|
||||
"engines": {
|
||||
"node": ">=5"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Bret Copeland",
|
||||
"email": "bret@atlantisflight.org",
|
||||
"url": "https://github.com/bretcope"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"better-assert": "*",
|
||||
"mocha": "^8.1",
|
||||
"pm2-axon": "^4.0.0"
|
||||
},
|
||||
"main": "index",
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/unitech/pm2-axon-rpc.git"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user