Comparing version 0.7.0 to 0.8.0
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
var sys = require('sys'); | ||
var util = require('util'); | ||
var chr = String.fromCharCode; | ||
@@ -252,6 +252,6 @@ | ||
var number = s.charCodeAt(i) <= 15 ? "0" + s.charCodeAt(i).toString(16) : s.charCodeAt(i).toString(16); | ||
sys.debug(number+' : ');} | ||
util.debug(number+' : ');} | ||
else { | ||
var number = s.charCodeAt(i) <= 15 ? "0" + s.charCodeAt(i).toString(16) : s.charCodeAt(i).toString(16); | ||
sys.debug(number+' : '+ s.charAt(i));} | ||
util.debug(number+' : '+ s.charAt(i));} | ||
} | ||
@@ -268,3 +268,3 @@ }; | ||
sys.puts(array); | ||
util.puts(array); | ||
} | ||
@@ -274,5 +274,5 @@ | ||
for (var i=0; i<s.length; i++) { | ||
if (s.charCodeAt(i)<32) {sys.puts(s.charCodeAt(i)+' : ');} | ||
else {sys.puts(s.charCodeAt(i)+' : '+ s.charAt(i));} | ||
if (s.charCodeAt(i)<32) {util.puts(s.charCodeAt(i)+' : ');} | ||
else {util.puts(s.charCodeAt(i)+' : '+ s.charAt(i));} | ||
} | ||
}; |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
var sys = require('sys'), | ||
var util = require('util'), | ||
EventEmitter = require("events").EventEmitter, | ||
@@ -96,3 +96,3 @@ net = require('net'), | ||
}; | ||
sys.inherits(Connection, EventEmitter); | ||
util.inherits(Connection, EventEmitter); | ||
@@ -133,1 +133,113 @@ Connection.prototype.end = function() { | ||
} | ||
var child_process = require('child_process'); | ||
var StdIOConnection = exports.StdIOConnection = function(command, options) { | ||
var command_parts = command.split(' '); | ||
command = command_parts[0]; | ||
var args = command_parts.splice(1,command_parts.length -1); | ||
var child = this.child = child_process.spawn(command,args); | ||
var self = this; | ||
EventEmitter.call(this); | ||
this._debug = options.debug || false; | ||
this.connection = child.stdin; | ||
this.options = options || {}; | ||
this.transport = this.options.transport || ttransport.TFramedTransport; | ||
this.protocol = this.options.protocol || tprotocol.TBinaryProtocol; | ||
this.offline_queue = []; | ||
if(this._debug === true){ | ||
this.child.stderr.on('data',function(err){ | ||
console.log(err.toString(),'CHILD ERROR'); | ||
}); | ||
this.child.on('exit',function(code,signal){ | ||
console.log(code+':'+signal,'CHILD EXITED'); | ||
}); | ||
} | ||
this.frameLeft = 0; | ||
this.framePos = 0; | ||
this.frame = null; | ||
this.connected = true; | ||
self.offline_queue.forEach(function(data) { | ||
self.connection.write(data); | ||
}); | ||
this.connection.addListener("error", function(err) { | ||
self.emit("error", err); | ||
}); | ||
// Add a close listener | ||
this.connection.addListener("close", function() { | ||
self.emit("close"); | ||
}); | ||
child.stdout.addListener("data", self.transport.receiver(function(transport_with_data) { | ||
var message = new self.protocol(transport_with_data); | ||
try { | ||
var header = message.readMessageBegin(); | ||
var dummy_seqid = header.rseqid * -1; | ||
var client = self.client; | ||
client._reqs[dummy_seqid] = function(err, success){ | ||
transport_with_data.commitPosition(); | ||
var callback = client._reqs[header.rseqid]; | ||
delete client._reqs[header.rseqid]; | ||
if (callback) { | ||
callback(err, success); | ||
} | ||
}; | ||
client['recv_' + header.fname](message, header.mtype, dummy_seqid); | ||
} | ||
catch (e) { | ||
if (e instanceof ttransport.InputBufferUnderrunError) { | ||
transport_with_data.rollbackPosition(); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
})); | ||
}; | ||
util.inherits(StdIOConnection, EventEmitter); | ||
StdIOConnection.prototype.end = function() { | ||
this.connection.end(); | ||
} | ||
StdIOConnection.prototype.write = function(data) { | ||
if (!this.connected) { | ||
this.offline_queue.push(data); | ||
return; | ||
} | ||
this.connection.write(data); | ||
} | ||
exports.createStdIOConnection = function(command,options){ | ||
return new StdIOConnection(command,options); | ||
}; | ||
exports.createStdIOClient = function(cls,connection) { | ||
if (cls.Client) { | ||
cls = cls.Client; | ||
} | ||
var client = new cls(new connection.transport(undefined, function(buf) { | ||
connection.write(buf); | ||
}), connection.protocol); | ||
// TODO clean this up | ||
connection.client = client; | ||
return client; | ||
} |
@@ -25,3 +25,5 @@ /* | ||
exports.createConnection = connection.createConnection; | ||
exports.createStdIOClient = connection.createStdIOClient; | ||
exports.createStdIOConnection = connection.createStdIOConnection; | ||
exports.createServer = require('./server').createServer; |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
var sys = require('sys'), | ||
var util = require('util'), | ||
Thrift = require('./thrift'), | ||
@@ -38,3 +38,3 @@ Type = Thrift.Type; | ||
} | ||
sys.inherits(TProtocolException, Error); | ||
util.inherits(TProtocolException, Error); | ||
@@ -41,0 +41,0 @@ var TBinaryProtocol = exports.TBinaryProtocol = function(trans, strictRead, strictWrite) { |
@@ -19,4 +19,3 @@ /* | ||
*/ | ||
var sys = require('sys'), | ||
net = require('net'); | ||
var net = require('net'); | ||
@@ -23,0 +22,0 @@ var ttransport = require('./transport'); |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
var sys = require('sys'); | ||
var util = require('util'); | ||
@@ -53,3 +53,3 @@ var Type = exports.Type = { | ||
} | ||
sys.inherits(TException, Error); | ||
util.inherits(TException, Error); | ||
@@ -72,3 +72,3 @@ var TApplicationExceptionType = exports.TApplicationExceptionType = { | ||
} | ||
sys.inherits(TApplicationException, TException); | ||
util.inherits(TApplicationException, TException); | ||
@@ -142,3 +142,3 @@ TApplicationException.prototype.read = function(input) { | ||
exports.inherits = function(constructor, superConstructor) { | ||
sys.inherits(constructor, superConstructor); | ||
util.inherits(constructor, superConstructor); | ||
} |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"author": | ||
@@ -23,3 +23,3 @@ { "name": "Apache Thrift Developers", | ||
{ "mail": "dev@thrift.apache.org", | ||
"web": "https://issues.apache.org/jira/browse/THRIFT" | ||
"url": "https://issues.apache.org/jira/browse/THRIFT" | ||
}, | ||
@@ -26,0 +26,0 @@ "directories" : { "lib" : "./lib/thrift" }, |
@@ -1,13 +0,23 @@ | ||
# node-thrift | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
Thrift protocol implementation for nodejs. As of version 0.0.1, the basic | ||
protocol has been implemented. A Thrift compiler that will generate the .js | ||
files from a Thrift specification is being implemented as well, see the | ||
Thrift Compiler section below. | ||
NOTE: By default, node-thrift uses TFramedTransport. Using a popular | ||
example, this is enabled by default in Cassandra 0.7 (but configuration must be | ||
changed in Cassandra 0.6.x and earlier). See the | ||
[examples](https://github.com/wadey/node-thrift/tree/master/examples) folder | ||
to see how to enable TBufferedTransport (added in 0.7.0). | ||
NOTE: you must use the framed thrift transport, TFramedTransport in most | ||
implementations, on the server side. Using a popular example, this is enabled | ||
by default in Cassandra 0.7 (but configuration must be changed in Cassandra | ||
0.6.x and earlier). | ||
@@ -20,4 +30,3 @@ ## Install | ||
A Thrift compiler is included in the 0.6.0 release of Thrift. You can | ||
compile nodejs sources by running the following: | ||
You can compile nodejs sources by running the following: | ||
@@ -50,8 +59,4 @@ thrift --gen js:node thrift_file | ||
## Libraries using node-thrift | ||
* [yukim/node_cassandra](https://github.com/yukim/node_cassandra) | ||
## Custom client and server example | ||
An example based on the one shown on the Thrift front page is included in the [examples](https://github.com/wadey/node-thrift/tree/master/examples) folder. | ||
An example based on the one shown on the Thrift front page is included in the examples/ folder. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
0
61
0
51693
18
1284
5