Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/polixjs/polix-rpc
rpc plugin for polix
https://github.com/polixjs/polix-rpc
ast kirito nodejs parser rpc tokenizer
Last synced: 2 months ago
JSON representation
rpc plugin for polix
- Host: GitHub
- URL: https://github.com/polixjs/polix-rpc
- Owner: polixjs
- License: mit
- Created: 2018-06-26T02:02:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T13:46:55.000Z (almost 3 years ago)
- Last Synced: 2024-02-18T09:57:38.147Z (12 months ago)
- Topics: ast, kirito, nodejs, parser, rpc, tokenizer
- Language: JavaScript
- Homepage: https://cnodejs.org/topic/5b63b25e792f59ae501bf71c
- Size: 20.5 KB
- Stars: 10
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# polix-rpc
rpc plugin for polix[![Travis](https://img.shields.io/travis/polixjs/polix-rpc.svg?style=for-the-badge)](https://travis-ci.org/polixjs/polix-rpc)
## 架构图
[![polix-rpc](https://raw.githubusercontent.com/rickyes/rickyes.github.io/master/image/mqt_rpc.jpg)](https://raw.githubusercontent.com/rickyes/rickyes.github.io/master/image/mqt_rpc.jpg)## Get Start
#### Kirito File
``` shell
# testservice testService {
method ping (reqMsg, resMsg)
}struct reqMsg {
@1 age = Int16;
@2 name = Text;
}struct resMsg {
@1 age = Int16;
@2 name = Text;
}
```#### Server
``` js
'use strict';const pRPC = require('polix-rpc');
const path = require('path');
const kiritoProto = './protocol/test.kirito';
const server = new pRPC.Server();
const proto = pRPC.load(path.join(__dirname, kiritoProto));function test(call, cb) {
cb(null, {age: call.age, name: call.name});
}server.addKiritoService(proto.testService, {ping: test});
server.listen(10003);
```#### Client
``` js
'use strict';const pRPC = require('polix-rpc');
const path = require('path');
const kiritoProto = './protocol/test.kirito';
const proto = pRPC.load(path.join(__dirname, kiritoProto));
const client = new pRPC.Client({host: 'localhost', port: 10003}, proto.testService);client.ping({age: 23, name: 'Ricky 泽阳'}, function (err, result) {
if (err) {
throw new Error(err.message);
}
console.log(result);
});
```## Author
polix-rpc © [Ricky 泽阳](https://github.com/rickyes), Released under the MIT License.