node-thrift-service
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -151,3 +151,3 @@ /** | ||
* @param alias | ||
* @returns {Promise<U>|Thenable<U>|Promise.<T>} | ||
* @returns {Promises|bluebird|*} | ||
* @private | ||
@@ -213,25 +213,22 @@ */ | ||
// new | ||
let connection = thrift.createConnection(data.host, data.port), | ||
client = thrift.createClient(processor, connection), | ||
clean = () => { | ||
// delete from _adapter and _clients | ||
self._clients[alias].remove(data.id); | ||
self._adapter.del({alias: alias, id: data.id}) | ||
.then(() => { | ||
self.emit(EVENT.LOG.INFO, | ||
alias + ' delete client ' + data.id); | ||
}) | ||
.catch((err) => { | ||
self.emit(EVENT.LOG.ERROR, | ||
alias + ' delete client ' + data.id, err); | ||
}); | ||
}; | ||
data.connection = thrift.createConnection(data.host, data.port); | ||
data.client = thrift.createClient(processor, data.connection); | ||
let clean = () => { | ||
// delete from _adapter and _clients | ||
self._clients[alias].remove(data.id); | ||
self._adapter.del({alias: alias, id: data.id}) | ||
.then(() => { | ||
self.emit(EVENT.LOG.INFO, | ||
alias + ' delete client ' + data.id); | ||
}) | ||
.catch((err) => { | ||
self.emit(EVENT.LOG.ERROR, | ||
alias + ' delete client ' + data.id, err); | ||
}); | ||
}; | ||
// cannot connect | ||
connection.on('error', clean); | ||
connection.on('close', clean); | ||
data.connection.on('error', clean); | ||
data.connection.on('close', clean); | ||
// add | ||
self._clients[alias].append(_.merge(data, { | ||
connection: connection, | ||
client : client | ||
})); | ||
self._clients[alias].append(data); | ||
@@ -238,0 +235,0 @@ self.emit(EVENT.LOG.INFO, alias + ' add client ' + data.id); |
@@ -102,3 +102,3 @@ /** | ||
return new Promises((resolve, reject) => { | ||
client.call(cmsg, function (err, rmsg) { | ||
client.call(cmsg, (err, rmsg) => { | ||
if (err) { | ||
@@ -105,0 +105,0 @@ return reject(err); |
{ | ||
"name": "node-thrift-service", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "use redis/zookeeper to publish thrift service, manage thrift server/client", | ||
@@ -20,4 +20,4 @@ "author": "zzxun <xtkml.g@gmail.com>", | ||
"dependencies": { | ||
"bluebird": "~3.1.1", | ||
"lodash": "~4.0.0", | ||
"bluebird": "~3.3.4", | ||
"lodash": "~4.6.0", | ||
"redis": "~2.4.2", | ||
@@ -24,0 +24,0 @@ "thrift": "~0.9.3", |
@@ -23,3 +23,2 @@ # node-thrift-service | ||
ThriftServer | ||
@@ -146,7 +145,5 @@ | ||
- `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 | ||
- `.call(alias, action, params, [callback])` : use inner `msg.thrift` | ||
@@ -156,3 +153,2 @@ - 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` | ||
@@ -162,3 +158,2 @@ - find all services (by `alias`), and create thrift tcp connection | ||
- return `client` with {Promise|bluebird} or `callback(err, client)` | ||
- `.on(EVENT)` : | ||
@@ -170,6 +165,4 @@ - `ready` : server initial `.on('ready', (info) => {...})` | ||
| ||
# TEST | ||
@@ -176,0 +169,0 @@ |
@@ -15,6 +15,3 @@ /** | ||
adapter: { | ||
name : 'zookeeper', | ||
options: { | ||
connect: '172.16.82.182:2181' | ||
} | ||
name: 'zookeeper' | ||
} | ||
@@ -27,4 +24,4 @@ }); | ||
c.call('utils', 'test', []).then(console.log).catch(console.error); | ||
c.call('lodash', 'isString', [1]).then(console.log).catch(console.error); | ||
c.call('utils', 'getUnusedPort', [8000]).then(console.log).catch(console.error); | ||
c.call('lodash', 'isString', ['a']).then(console.log).catch(console.error); | ||
@@ -31,0 +28,0 @@ c.call('utils', 'test', []).then(console.log).catch(console.error); |
@@ -16,10 +16,3 @@ /** | ||
// test | ||
let s = new ThriftServer({ | ||
adapter: { | ||
name : 'zookeeper', | ||
options: { | ||
connect: '172.16.82.182:2181' | ||
} | ||
} | ||
}); | ||
let s = new ThriftServer(); | ||
@@ -26,0 +19,0 @@ s.on('debug', console.log); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166970
2003
171
+ Addedbluebird@3.3.5(transitive)
+ Addedlodash@4.6.1(transitive)
- Removedbluebird@3.1.5(transitive)
- Removedlodash@4.0.1(transitive)
Updatedbluebird@~3.3.4
Updatedlodash@~4.6.0