Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-thrift-service

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-thrift-service - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

lib/zookeeper.js

@@ -56,3 +56,3 @@ /**

* @param {String|Object} data
* @returns {*|Promise|bluebird|*}
* @returns {Promise|bluebird|*}
*/

@@ -59,0 +59,0 @@ save(key, data) {

{
"name": "node-thrift-service",
"version": "1.0.0",
"version": "1.0.1",
"description": "use redis/zookeeper to publish thrift service, manage thrift server/client",

@@ -20,7 +20,7 @@ "author": "zzxun <xtkml.g@gmail.com>",

"dependencies": {
"bluebird": "^3.1.1",
"lodash": "^4.0.0",
"redis": "^2.4.2",
"thrift": "^0.9.3",
"zookeeper": "^3.4.7-2"
"bluebird": "~3.1.1",
"lodash": "~4.0.0",
"redis": "~2.4.2",
"thrift": "~0.9.3",
"zookeeper": "~3.4.7-2"
},

@@ -27,0 +27,0 @@ "engines": {

@@ -12,4 +12,2 @@ # node-thrift-service

Features:

@@ -21,4 +19,2 @@

# USAGE

@@ -33,14 +29,31 @@

``` javascript
server = new ThriftServer({
services: {
alias : 'lodash',
service: _,
actions: ['isString', 'no_such_action']
const ThriftServer = require('node-thrift-service').ThriftServer;
let server = new ThriftServer({
adapter: {
name : 'zookeeper',
options: {
connect : '127.0.0.1:2181',
timeout : 200000,
debug_level : ZooKeeper.ZOO_LOG_LEVEL_ERROR,
host_order_deterministic: false,
data_as_buffer : false
}
}
});
server.on('log', console.log);
server.on('debug', console.log);
server.on('info', console.log);
server.on('error', console.error);
server.on('listening', console.log);
server.on('ready', (info) => {
console.log(info);
server.add({
alias : 'lodash',
service: _,
actions: ['isString', 'no_such_action']
});
});
// ThriftServer host: xx.xx.xx.xx , port: 7007

@@ -54,13 +67,29 @@ ```

``` javascript
client = new ThriftClient();
const ThriftServer = require('node-thrift-service').ThriftClient;
client.on('log', console.log);
let client = new ThriftClient({
adapter: {
name : 'zookeeper',
options: {
connect : '127.0.0.1:2181',
timeout : 200000,
debug_level : ZooKeeper.ZOO_LOG_LEVEL_ERROR,
host_order_deterministic: false,
data_as_buffer : false
}
}
});
client.on('debug', console.log);
client.on('info', console.log);
client.on('error', console.error);
client.on('ready', console.log);
client.call('lodash', 'isString', ['a']).then(console.log);
// true
client.call('lodash', 'no_such_action').catch(console.error);
// method forbidden
client.on('ready', (info) => {
console.log(info);
client.call('lodash', 'isString', ['a']).then(console.log);
// true
client.call('lodash', 'no_such_action', []).catch(console.error);
// error
});
```

@@ -77,3 +106,3 @@

- `[options.adapter]` : optional {Object}, include:
- `name`='zookeeper' : 'redis' or 'zookeeper'
- `name='zookeeper'` : 'redis' or 'zookeeper'
- `options`={} : redis: [node_redis](https://github.com/NodeRedis/node_redis) , zookeeper: [node-zookeeper](https://github.com/yfinkelstein/node-zookeeper)

@@ -88,8 +117,6 @@ - `[options.services]` : optional {Object|Array}, each service include:

#### use-defined gen-nodejs
- `[options.adapter]` : optional {Object}, include:
- `name`='zookeeper' : 'redis' or 'zookeeper'
- `name='zookeeper'` : 'redis' or 'zookeeper'
- `options`={} : redis: [node_redis](https://github.com/NodeRedis/node_redis) , zookeeper: [node-zookeeper](https://github.com/yfinkelstein/node-zookeeper)

@@ -104,19 +131,17 @@ - ``[options.thrift]` : optional {Object}, include:

#### API
- `.add(services)` : invalid with 'use-defined gen-nodejs'
- `services` just as `options.services`
- return {Promise|bluebird}
- `.add(services)` : invalid with 'use-defined gen-nodejs', return {Promise|bluebird}
- `[alias]` : {Function|String} unique name of each service, or use `service.name` or `service.identity`
- `service` : {Object} origin service object
- `[actions]` : {Array|String} permissions, or allow all service actions, ONLY support PROMISE/SYNC
- `.on(EVENT)` :
- `listening` : server initial
- `log` : log info
- `error` : error info
- `.server` get thrift.createServer
- `.host` get host
- `.port` get port
- `ready` : server initial `.on('ready', (info) => {...})`
- `debug` : debug log `.on('ready', (info) => {...})`
- `info` : info log, `.on('info', (info) => {...})`
- `error` : error log, `.on('info', (err) => {…})`
- `.server()` get thrift.createServer
- `.host()` get host
- `.port()` get port
### ThriftClient(options) :

@@ -127,5 +152,7 @@

- `options={}` : redis: [node_redis](https://github.com/NodeRedis/node_redis) , zookeeper: [node-zookeeper](https://github.com/yfinkelstein/node-zookeeper)
- `[options.thrifts]` : optional {Object}, for user-defined
- `alias` // for search thrift server
- processor // gen-nodejs thrift processor
- `processor` // gen-nodejs thrift processor
- `.call(alias, action, params, [callback])` : use inner `msg.thrift`

@@ -135,2 +162,3 @@ - find all services (by `alias`), and create thrift tcp connection

- return `result` with {Promise|bluebird} or `callback(err, result)`
- `.call(alias, [callback])` : for `user-defined.thrift` return `thrift.createClient`

@@ -140,11 +168,13 @@ - find all services (by `alias`), and create thrift tcp connection

- return `client` with {Promise|bluebird} or `callback(err, client)`
- `.on(EVENT)` :
- `ready` : client ready
- `log` : log info
- `error` : error info
- `ready` : server initial `.on('ready', (info) => {...})`
- `debug` : debug log `.on('ready', (info) => {...})`
- `info` : info log, `.on('info', (info) => {...})`
- `error` : error log, `.on('info', (err) => {…})`
# TEST

@@ -151,0 +181,0 @@

@@ -15,3 +15,6 @@ /**

adapter: {
name: 'zookeeper'
name : 'zookeeper',
options: {
connect: '172.16.82.182:2181'
}
}

@@ -18,0 +21,0 @@ });

@@ -17,10 +17,7 @@ /**

let s = new ThriftServer({
services: [{
alias : 'utils',
service: utils
}, {
service: _
}],
adapter: {
name: 'zookeeper'
name : 'zookeeper',
options: {
connect: '172.16.82.182:2181'
}
}

@@ -32,2 +29,11 @@ });

s.on('error', console.error);
s.on('ready', console.log);
s.on('ready', (data) => {
console.log(data);
s.add([{
alias : 'utils',
service: utils
}, {
service: _
}]);
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc