/
package.json
41 lines (41 loc) · 4.17 KB
/
package.json
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
36
37
38
39
40
41
{
"name": "rpc-streamx",
"version": "1.1.0",
"description": "very simple rpc. use with any thing that has .pipe()",
"homepage": "http://github.com/kenokabe/rpc-streamx",
"repository":
{
"type": "git",
"url": "git://github.com/kenokabe/rpc-streamx.git"
},
"dependencies":
{
"stream-serializer": "~1.0.0",
"through": "~2.3.1"
},
"devDependencies":
{
"event-stream": "~2",
"tape": "~0.3.3"
},
"author":
{
"name": "Dominic Tarr",
"email": "dominic.tarr@gmail.com",
"url": "dominictarr.com"
},
"optionalDependencies":
{},
"scripts":
{
"test": "set -e; for t in test/*.js; do node $t; done"
},
"readme": "#rpc-stream\n\n`RpcStream` is a dead simple (75 loc) rpc system that works over any full-duplex text/byte/json stream.\nThere's also a [Python port](https://github.com/riga/rpyc-stream), e.g. for cross-language RPC-over-SSH.\n\n## ports\n\n* [rpyc-stream](https://github.com/riga/rpyc-stream) Python\n\n## rant\n\nThere are a bunch of people have already written node rpc systems, but most of them has done it _right_ yet.\nMy beef is that all these systems is that they are tightly coupled to, or wrapped around servers. what if I want to encrypt the messages? what if I want to send the messages over stdin/out, or over ssh? of write them to a temp file? there is one abstraction that matches all of these cases; the `Stream`\n\nI should just be able to do this:\n\n``` js\n REMOTE_SSH_STREAM //<-- pipe data from a remote source\n .pipe(DECRYPT_STREAM) //through some ('middleware') streams (ssh already encrypts, but I'm paranoid)\n .pipe(GUNZIP_STREAM)\n .pipe(RPC) //<--- pipe the data through the RPC system.\n .pipe(GZIP_STREAM)\n .pipe(ENCYPT_STREAM)\n .pipe(REMOTE_SSH_STREAM) //<-- and back to the remote\n\n //with something very similar on the other side.\n```\nRPC framework (AHEM! RPC MODULE!), _you_ just worry about calling the right function, _I'll_ decide where you go...\n\nupdate: [dnode@1.0.0](https://github.com/substack/dnode) now has first class streams, and you can pipe it where you like! \n\n## usage\n\n```\nvar rpc = require('rpc-stream')\n\n//create a server, that answers questions.\n//pass in functions that may be called remotely.\nvar server = rpc({hello: function (name, cb) {\n cb(null, 'hello, '+name)\n}})\n\n//create a client, that asks questions.\nvar client = rpc()\n\n//pipe rpc instances together!\nclient.pipe(server).pipe(client)\n\nvar remote = client.wrap(['hello'])\nremote.hello('JIM', function (err, mess) {\n if(err) throw err\n console.log(mess)\n})\n```\n\n### rpc(methods, isRaw)\n\nreturns a `RpcStream` that will call `methods` when written to. If the `isRaw` parameter is set to `true`, `JSON.stringify()`\nis turned off and you just get a stream of objects, in case you want to do your own parsing/stringifying.\n\n### RpcStream\\#wrap(methodNames)\n\nreturns a wrapped object with the remote's methods.\nthe client needs to already know the names of the methods.\naccepts a string, and array of strings, or a object.\nif it's an object, `wrap` will use the keys as the method names. \n\n```\n//create rpc around the fs module.\nvar fsrpc = rpc(require('fs'))\n//pipe, etc\n```\n\nthen, in another process...\n\n```\nvar fsrpc = rpc()\n//pipe, etc\n\n//wrap, with the right method names.\nvar remoteFs = fs.wrap(require('fs'))\n\nremoteFs.mkdir('/tmp/whatever', function (err, dir) {\n //yay! \n})\n\n```\n\nnow, the second process can call the `fs` module in the first process!\n`wrap` does not use the methods for anything. it just wants the names.\n\n### RpcStream#rpc(name, args, cb)\n\nthis gets invoked by wrap. but you could call it directly.\n\n``` js\nrpc().wrap('hello').hello(name, callback)\n//is the same as\nrpc().rpc('hello', [name], callback)\n```\n\n### RpcStream#pipe\n\nthis is why we are here. read [this](http://nodejs.org/api/stream.html#stream_stream_pipe_destination_options) and [this](https://github.com/joyent/node/blob/master/lib/stream.js)\n\n\n## license\n\nMIT/APACHE2\n",
"readmeFilename": "readme.markdown",
"bugs":
{
"url": "https://github.com/kenokabe/rpc-streamx/issues"
},
"_id": "rpc-streamx@1.1.0",
"_from": "rpc-streamx@"
}