Upgrading dependency to Thrift 0.12.0

This commit is contained in:
Renan DelValle 2018-11-27 18:03:50 -08:00
parent 3e4590dcc0
commit 356978cb42
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
1302 changed files with 101701 additions and 26784 deletions

View file

@ -34,7 +34,7 @@
* all features must be scoped within the Thrift namespace.
* @namespace
* @example
* var transport = new Thrift.Transport("http://localhost:8585");
* var transport = new Thrift.Transport('http://localhost:8585');
* var protocol = new Thrift.Protocol(transport);
* var client = new MyThriftSvcClient(protocol);
* var result = client.MyMethod();
@ -46,7 +46,7 @@ var Thrift = {
* @const {string} Version
* @memberof Thrift
*/
Version: '0.10.0',
Version: '1.0.0-dev',
/**
* Thrift IDL type string to Id mapping.
@ -70,23 +70,23 @@ var Thrift = {
* @property {number} UTF16 - Array of bytes representing a string of UTF16 encoded characters.
*/
Type: {
'STOP' : 0,
'VOID' : 1,
'BOOL' : 2,
'BYTE' : 3,
'I08' : 3,
'DOUBLE' : 4,
'I16' : 6,
'I32' : 8,
'I64' : 10,
'STRING' : 11,
'UTF7' : 11,
'STRUCT' : 12,
'MAP' : 13,
'SET' : 14,
'LIST' : 15,
'UTF8' : 16,
'UTF16' : 17
STOP: 0,
VOID: 1,
BOOL: 2,
BYTE: 3,
I08: 3,
DOUBLE: 4,
I16: 6,
I32: 8,
I64: 10,
STRING: 11,
UTF7: 11,
STRUCT: 12,
MAP: 13,
SET: 14,
LIST: 15,
UTF8: 16,
UTF16: 17
},
/**
@ -98,10 +98,10 @@ var Thrift = {
* @property {number} ONEWAY - Oneway RPC call from client to server with no response.
*/
MessageType: {
'CALL' : 1,
'REPLY' : 2,
'EXCEPTION' : 3,
'ONEWAY' : 4
CALL: 1,
REPLY: 2,
EXCEPTION: 3,
ONEWAY: 4
},
/**
@ -130,7 +130,7 @@ var Thrift = {
function F() {}
F.prototype = superConstructor.prototype;
constructor.prototype = new F();
constructor.prototype.name = name || "";
constructor.prototype.name = name || '';
}
};
@ -171,17 +171,17 @@ Thrift.TException.prototype.getMessage = function() {
* @property {number} UNSUPPORTED_CLIENT_TYPE - Unused.
*/
Thrift.TApplicationExceptionType = {
'UNKNOWN' : 0,
'UNKNOWN_METHOD' : 1,
'INVALID_MESSAGE_TYPE' : 2,
'WRONG_METHOD_NAME' : 3,
'BAD_SEQUENCE_ID' : 4,
'MISSING_RESULT' : 5,
'INTERNAL_ERROR' : 6,
'PROTOCOL_ERROR' : 7,
'INVALID_TRANSFORM' : 8,
'INVALID_PROTOCOL' : 9,
'UNSUPPORTED_CLIENT_TYPE' : 10
UNKNOWN: 0,
UNKNOWN_METHOD: 1,
INVALID_MESSAGE_TYPE: 2,
WRONG_METHOD_NAME: 3,
BAD_SEQUENCE_ID: 4,
MISSING_RESULT: 5,
INTERNAL_ERROR: 6,
PROTOCOL_ERROR: 7,
INVALID_TRANSFORM: 8,
INVALID_PROTOCOL: 9,
UNSUPPORTED_CLIENT_TYPE: 10
};
/**
@ -194,7 +194,7 @@ Thrift.TApplicationExceptionType = {
*/
Thrift.TApplicationException = function(message, code) {
this.message = message;
this.code = typeof code === "number" ? code : 0;
this.code = typeof code === 'number' ? code : 0;
};
Thrift.inherits(Thrift.TApplicationException, Thrift.TException, 'TApplicationException');
@ -572,14 +572,16 @@ Thrift.TWebSocketTransport.prototype = {
var clientCallback = callback;
return function(msg) {
self.setRecvBuffer(msg);
clientCallback();
if (clientCallback) {
clientCallback();
}
};
}()));
} else {
//Queue the send to go out __onOpen
this.send_pending.push({
buf: this.send_buf,
cb: callback
cb: callback
});
}
},
@ -590,8 +592,8 @@ Thrift.TWebSocketTransport.prototype = {
//If the user made calls before the connection was fully
//open, send them now
this.send_pending.forEach(function(elem) {
this.socket.send(elem.buf);
this.callbacks.push((function() {
self.socket.send(elem.buf);
self.callbacks.push((function() {
var clientCallback = elem.cb;
return function(msg) {
self.setRecvBuffer(msg);
@ -614,7 +616,7 @@ Thrift.TWebSocketTransport.prototype = {
},
__onError: function(evt) {
console.log("Thrift WebSocket Error: " + evt.toString());
console.log('Thrift WebSocket Error: ' + evt.toString());
this.socket.close();
},
@ -1256,7 +1258,12 @@ Thrift.Protocol.prototype = {
/** Deserializes the end of a list. */
readListEnd: function() {
this.readFieldEnd();
var pos = this.rpos.pop() - 2;
var st = this.rstack;
st.pop();
if (st instanceof Array && st.length > pos && st[pos].length > 0) {
st.push(st[pos].shift());
}
},
/**
@ -1312,7 +1319,11 @@ Thrift.Protocol.prototype = {
if (f.length === 0) {
r.value = undefined;
} else {
r.value = f.shift();
if (!f.isReversed) {
f.reverse();
f.isReversed = true;
}
r.value = f.pop();
}
} else if (f instanceof Object) {
for (var i in f) {
@ -1431,6 +1442,9 @@ Thrift.Protocol.prototype = {
}
this.readListEnd();
return null;
default:
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.INVALID_DATA);
}
}
};
@ -1440,23 +1454,23 @@ Thrift.Protocol.prototype = {
* Initializes a MutilplexProtocol Implementation as a Wrapper for Thrift.Protocol
* @constructor
*/
Thrift.MultiplexProtocol = function (srvName, trans, strictRead, strictWrite) {
Thrift.MultiplexProtocol = function(srvName, trans, strictRead, strictWrite) {
Thrift.Protocol.call(this, trans, strictRead, strictWrite);
this.serviceName = srvName;
};
Thrift.inherits(Thrift.MultiplexProtocol, Thrift.Protocol, 'multiplexProtocol');
/** Override writeMessageBegin method of prototype*/
Thrift.MultiplexProtocol.prototype.writeMessageBegin = function (name, type, seqid) {
Thrift.MultiplexProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
if (type === Thrift.MessageType.CALL || type === Thrift.MessageType.ONEWAY) {
Thrift.Protocol.prototype.writeMessageBegin.call(this, this.serviceName + ":" + name, type, seqid);
Thrift.Protocol.prototype.writeMessageBegin.call(this, this.serviceName + ':' + name, type, seqid);
} else {
Thrift.Protocol.prototype.writeMessageBegin.call(this, name, type, seqid);
}
};
Thrift.Multiplexer = function () {
Thrift.Multiplexer = function() {
this.seqid = 0;
};
@ -1471,12 +1485,12 @@ Thrift.Multiplexer = function () {
* var protocol = new Thrift.Protocol(transport);
* var client = mp.createClient('AuthService', AuthServiceClient, transport);
*/
Thrift.Multiplexer.prototype.createClient = function (serviceName, SCl, transport) {
Thrift.Multiplexer.prototype.createClient = function(serviceName, SCl, transport) {
if (SCl.Client) {
SCl = SCl.Client;
}
var self = this;
SCl.prototype.new_seqid = function () {
SCl.prototype.new_seqid = function() {
self.seqid += 1;
return self.seqid;
};
@ -1519,7 +1533,7 @@ copyList = function(lst, types) {
return result;
};
copyMap = function(obj, types){
copyMap = function(obj, types) {
if (!obj) {return obj; }
@ -1534,8 +1548,8 @@ copyMap = function(obj, types){
var Type = type;
var result = {}, val;
for(var prop in obj) {
if(obj.hasOwnProperty(prop)) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
val = obj[prop];
if (type === null) {
result[prop] = val;