@databricks/sql 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/DBSQLClient.d.ts +15 -8
- package/dist/DBSQLClient.js +76 -81
- package/dist/DBSQLClient.js.map +1 -1
- package/dist/DBSQLOperation/FetchResultsHelper.d.ts +3 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js +4 -3
- package/dist/DBSQLOperation/FetchResultsHelper.js.map +1 -1
- package/dist/DBSQLOperation/index.d.ts +19 -10
- package/dist/DBSQLOperation/index.js +178 -47
- package/dist/DBSQLOperation/index.js.map +1 -1
- package/dist/DBSQLParameter.d.ts +33 -0
- package/dist/DBSQLParameter.js +87 -0
- package/dist/DBSQLParameter.js.map +1 -0
- package/dist/DBSQLSession.d.ts +10 -7
- package/dist/DBSQLSession.js +188 -23
- package/dist/DBSQLSession.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.d.ts +3 -3
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js +3 -4
- package/dist/connection/auth/DatabricksOAuth/AuthorizationCode.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.d.ts +11 -3
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js +74 -20
- package/dist/connection/auth/DatabricksOAuth/OAuthManager.js.map +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.d.ts +4 -6
- package/dist/connection/auth/DatabricksOAuth/index.js +1 -1
- package/dist/connection/auth/DatabricksOAuth/index.js.map +1 -1
- package/dist/connection/auth/PlainHttpAuthentication.d.ts +6 -3
- package/dist/connection/auth/PlainHttpAuthentication.js +1 -0
- package/dist/connection/auth/PlainHttpAuthentication.js.map +1 -1
- package/dist/connection/connections/HttpConnection.d.ts +16 -9
- package/dist/connection/connections/HttpConnection.js +60 -51
- package/dist/connection/connections/HttpConnection.js.map +1 -1
- package/dist/connection/connections/ThriftHttpConnection.d.ts +38 -0
- package/dist/connection/connections/ThriftHttpConnection.js +134 -0
- package/dist/connection/connections/ThriftHttpConnection.js.map +1 -0
- package/dist/connection/contracts/IAuthentication.d.ts +2 -2
- package/dist/connection/contracts/IConnectionOptions.d.ts +17 -19
- package/dist/connection/contracts/IConnectionProvider.d.ts +6 -3
- package/dist/contracts/IClientContext.d.ts +10 -0
- package/dist/{connection/contracts/IThriftConnection.js → contracts/IClientContext.js} +1 -1
- package/dist/contracts/IClientContext.js.map +1 -0
- package/dist/contracts/IDBSQLClient.d.ts +4 -0
- package/dist/contracts/IDBSQLSession.d.ts +34 -0
- package/dist/contracts/IDriver.d.ts +24 -0
- package/dist/contracts/IDriver.js +3 -0
- package/dist/contracts/IDriver.js.map +1 -0
- package/dist/errors/OperationStateError.js +2 -1
- package/dist/errors/OperationStateError.js.map +1 -1
- package/dist/errors/ParameterError.d.ts +2 -0
- package/dist/errors/ParameterError.js +6 -0
- package/dist/errors/ParameterError.js.map +1 -0
- package/dist/errors/StagingError.d.ts +2 -0
- package/dist/errors/StagingError.js +6 -0
- package/dist/errors/StagingError.js.map +1 -0
- package/dist/hive/HiveDriver.d.ts +8 -5
- package/dist/hive/HiveDriver.js +23 -23
- package/dist/hive/HiveDriver.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/result/ArrowResult.d.ts +3 -1
- package/dist/result/ArrowResult.js +6 -4
- package/dist/result/ArrowResult.js.map +1 -1
- package/dist/result/CloudFetchResult.d.ts +2 -1
- package/dist/result/CloudFetchResult.js +5 -3
- package/dist/result/CloudFetchResult.js.map +1 -1
- package/dist/result/JsonResult.d.ts +3 -1
- package/dist/result/JsonResult.js +2 -1
- package/dist/result/JsonResult.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.js +1 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -5
- package/thrift/TCLIService.d.ts +2 -1
- package/thrift/TCLIService.js +1 -1
- package/thrift/TCLIService_types.d.ts +11 -3
- package/thrift/TCLIService_types.js +41 -4
- package/dist/DBSQLOperation/CompleteOperationHelper.d.ts +0 -13
- package/dist/DBSQLOperation/CompleteOperationHelper.js +0 -56
- package/dist/DBSQLOperation/CompleteOperationHelper.js.map +0 -1
- package/dist/DBSQLOperation/OperationStatusHelper.d.ts +0 -16
- package/dist/DBSQLOperation/OperationStatusHelper.js +0 -138
- package/dist/DBSQLOperation/OperationStatusHelper.js.map +0 -1
- package/dist/DBSQLOperation/SchemaHelper.d.ts +0 -13
- package/dist/DBSQLOperation/SchemaHelper.js +0 -74
- package/dist/DBSQLOperation/SchemaHelper.js.map +0 -1
- package/dist/connection/contracts/IThriftConnection.d.ts +0 -4
- package/dist/connection/contracts/IThriftConnection.js.map +0 -1
- package/dist/node_modules/thrift/LICENSE +0 -306
- package/dist/node_modules/thrift/README.md +0 -210
- package/dist/node_modules/thrift/lib/nodejs/README.md +0 -142
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary.js +0 -168
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/binary_protocol.js +0 -367
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/browser.js +0 -49
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js +0 -186
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/compact_protocol.js +0 -915
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/connection.js +0 -396
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js +0 -54
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/framed_transport.js +0 -185
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_protocol.js +0 -258
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/header_transport.js +0 -341
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js +0 -292
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/index.js +0 -76
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/input_buffer_underrun_error.js +0 -32
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/int64_util.js +0 -91
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_parse.js +0 -299
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/json_protocol.js +0 -799
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/log.js +0 -87
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_processor.js +0 -63
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/multiplexed_protocol.js +0 -73
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/protocol.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/server.js +0 -123
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/thrift.js +0 -241
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/transport.js +0 -22
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/web_server.js +0 -567
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_connection.js +0 -286
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/ws_transport.js +0 -206
- package/dist/node_modules/thrift/lib/nodejs/lib/thrift/xhr_connection.js +0 -280
- package/dist/node_modules/thrift/package.json +0 -72
- package/dist/utils/areHeadersEqual.d.ts +0 -2
- package/dist/utils/areHeadersEqual.js +0 -49
- package/dist/utils/areHeadersEqual.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
var util = require('util');
|
|
21
|
-
|
|
22
|
-
var disabled = function () {};
|
|
23
|
-
var logFunc = console.log;
|
|
24
|
-
var logLevel = 'error'; // default level
|
|
25
|
-
|
|
26
|
-
function factory(level) {
|
|
27
|
-
return function () {
|
|
28
|
-
// better use spread syntax, but due to compatibility,
|
|
29
|
-
// use legacy method here.
|
|
30
|
-
var args = ['thrift: [' + level + '] '].concat(Array.from(arguments));
|
|
31
|
-
return logFunc(util.format.apply(null, args));
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var trace = disabled;
|
|
36
|
-
var debug = disabled;
|
|
37
|
-
var error = disabled;
|
|
38
|
-
var warning = disabled;
|
|
39
|
-
var info = disabled;
|
|
40
|
-
|
|
41
|
-
exports.setLogFunc = function (func) {
|
|
42
|
-
logFunc = func;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var setLogLevel = exports.setLogLevel = function (level) {
|
|
46
|
-
trace = debug = error = warning = info = disabled;
|
|
47
|
-
logLevel = level;
|
|
48
|
-
switch (logLevel) {
|
|
49
|
-
case 'trace':
|
|
50
|
-
trace = factory('TRACE');
|
|
51
|
-
case 'debug':
|
|
52
|
-
debug = factory('DEBUG');
|
|
53
|
-
case 'error':
|
|
54
|
-
error = factory('ERROR');
|
|
55
|
-
case 'warning':
|
|
56
|
-
warning = factory('WARN');
|
|
57
|
-
case 'info':
|
|
58
|
-
info = factory('INFO');
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// set default
|
|
63
|
-
setLogLevel(logLevel);
|
|
64
|
-
|
|
65
|
-
exports.getLogLevel = function () {
|
|
66
|
-
return logLevel;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.trace = function () {
|
|
70
|
-
return trace.apply(null, arguments);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
exports.debug = function () {
|
|
74
|
-
return debug.apply(null, arguments);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.error = function () {
|
|
78
|
-
return error.apply(null, arguments);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
exports.warning = function () {
|
|
82
|
-
return warning.apply(null, arguments);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
exports.info = function () {
|
|
86
|
-
return info.apply(null, arguments);
|
|
87
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
var Thrift = require('./thrift');
|
|
20
|
-
|
|
21
|
-
exports.MultiplexedProcessor = MultiplexedProcessor;
|
|
22
|
-
|
|
23
|
-
function MultiplexedProcessor(stream, options) {
|
|
24
|
-
this.services = {};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
MultiplexedProcessor.prototype.registerProcessor = function(name, handler) {
|
|
28
|
-
this.services[name] = handler;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
MultiplexedProcessor.prototype.process = function(inp, out) {
|
|
32
|
-
var begin = inp.readMessageBegin();
|
|
33
|
-
|
|
34
|
-
if (begin.mtype != Thrift.MessageType.CALL && begin.mtype != Thrift.MessageType.ONEWAY) {
|
|
35
|
-
throw new Thrift.TException('TMultiplexedProcessor: Unexpected message type');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var p = begin.fname.split(':');
|
|
39
|
-
var sname = p[0];
|
|
40
|
-
var fname = p[1];
|
|
41
|
-
|
|
42
|
-
if (! (sname in this.services)) {
|
|
43
|
-
throw new Thrift.TException('TMultiplexedProcessor: Unknown service: ' + sname);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//construct a proxy object which stubs the readMessageBegin
|
|
47
|
-
//for the service
|
|
48
|
-
var inpProxy = {};
|
|
49
|
-
|
|
50
|
-
for (var attr in inp) {
|
|
51
|
-
inpProxy[attr] = inp[attr];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
inpProxy.readMessageBegin = function() {
|
|
55
|
-
return {
|
|
56
|
-
fname: fname,
|
|
57
|
-
mtype: begin.mtype,
|
|
58
|
-
rseqid: begin.rseqid
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this.services[sname].process(inpProxy, out);
|
|
63
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
var util = require('util');
|
|
20
|
-
var Thrift = require('./thrift');
|
|
21
|
-
|
|
22
|
-
exports.Multiplexer = Multiplexer;
|
|
23
|
-
|
|
24
|
-
function Wrapper(serviceName, protocol, connection) {
|
|
25
|
-
|
|
26
|
-
function MultiplexProtocol(trans, strictRead, strictWrite) {
|
|
27
|
-
protocol.call(this, trans, strictRead, strictWrite);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
util.inherits(MultiplexProtocol, protocol);
|
|
31
|
-
|
|
32
|
-
MultiplexProtocol.prototype.writeMessageBegin = function(name, type, seqid) {
|
|
33
|
-
if (type == Thrift.MessageType.CALL || type == Thrift.MessageType.ONEWAY) {
|
|
34
|
-
connection.seqId2Service[seqid] = serviceName;
|
|
35
|
-
MultiplexProtocol.super_.prototype.writeMessageBegin.call(this,
|
|
36
|
-
serviceName + ":" + name,
|
|
37
|
-
type,
|
|
38
|
-
seqid);
|
|
39
|
-
} else {
|
|
40
|
-
MultiplexProtocol.super_.prototype.writeMessageBegin.call(this, name, type, seqid);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return MultiplexProtocol;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function Multiplexer() {
|
|
48
|
-
this.seqid = 0;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
Multiplexer.prototype.createClient = function(serviceName, ServiceClient, connection) {
|
|
52
|
-
if (ServiceClient.Client) {
|
|
53
|
-
ServiceClient = ServiceClient.Client;
|
|
54
|
-
}
|
|
55
|
-
var writeCb = function(buf, seqid) {
|
|
56
|
-
connection.write(buf,seqid);
|
|
57
|
-
};
|
|
58
|
-
var transport = new connection.transport(undefined, writeCb);
|
|
59
|
-
var protocolWrapper = new Wrapper(serviceName, connection.protocol, connection);
|
|
60
|
-
var client = new ServiceClient(transport, protocolWrapper);
|
|
61
|
-
var self = this;
|
|
62
|
-
client.new_seqid = function() {
|
|
63
|
-
self.seqid += 1;
|
|
64
|
-
return self.seqid;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
if (typeof connection.client !== 'object') {
|
|
68
|
-
connection.client = {};
|
|
69
|
-
}
|
|
70
|
-
connection.client[serviceName] = client;
|
|
71
|
-
|
|
72
|
-
return client;
|
|
73
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
module.exports.TBinaryProtocol = require('./binary_protocol');
|
|
21
|
-
module.exports.TCompactProtocol = require('./compact_protocol');
|
|
22
|
-
module.exports.TJSONProtocol = require('./json_protocol');
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
var constants = require('constants');
|
|
21
|
-
var net = require('net');
|
|
22
|
-
var tls = require('tls');
|
|
23
|
-
|
|
24
|
-
var TBufferedTransport = require('./buffered_transport');
|
|
25
|
-
var TBinaryProtocol = require('./binary_protocol');
|
|
26
|
-
var THeaderProtocol = require('./header_protocol');
|
|
27
|
-
var InputBufferUnderrunError = require('./input_buffer_underrun_error');
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Create a Thrift server which can serve one or multiple services.
|
|
31
|
-
* @param {object} processor - A normal or multiplexedProcessor (must
|
|
32
|
-
* be preconstructed with the desired handler).
|
|
33
|
-
* @param {ServerOptions} options - Optional additional server configuration.
|
|
34
|
-
* @returns {object} - The Apache Thrift Multiplex Server.
|
|
35
|
-
*/
|
|
36
|
-
exports.createMultiplexServer = function(processor, options) {
|
|
37
|
-
var transport = (options && options.transport) ? options.transport : TBufferedTransport;
|
|
38
|
-
var protocol = (options && options.protocol) ? options.protocol : TBinaryProtocol;
|
|
39
|
-
|
|
40
|
-
function serverImpl(stream) {
|
|
41
|
-
var self = this;
|
|
42
|
-
stream.on('error', function(err) {
|
|
43
|
-
self.emit('error', err);
|
|
44
|
-
});
|
|
45
|
-
stream.on('data', transport.receiver(function(transportWithData) {
|
|
46
|
-
var input = new protocol(transportWithData);
|
|
47
|
-
var outputCb = function(buf) {
|
|
48
|
-
try {
|
|
49
|
-
stream.write(buf);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
self.emit('error', err);
|
|
52
|
-
stream.end();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
var output = new protocol(new transport(undefined, outputCb));
|
|
57
|
-
// Read and write need to be performed on the same transport
|
|
58
|
-
// for THeaderProtocol because we should only respond with
|
|
59
|
-
// headers if the request contains headers
|
|
60
|
-
if (protocol === THeaderProtocol) {
|
|
61
|
-
output = input;
|
|
62
|
-
output.trans.onFlush = outputCb;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
do {
|
|
67
|
-
processor.process(input, output);
|
|
68
|
-
transportWithData.commitPosition();
|
|
69
|
-
} while (true);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
if (err instanceof InputBufferUnderrunError) {
|
|
72
|
-
//The last data in the buffer was not a complete message, wait for the rest
|
|
73
|
-
transportWithData.rollbackPosition();
|
|
74
|
-
}
|
|
75
|
-
else if (err.message === "Invalid type: undefined") {
|
|
76
|
-
//No more data in the buffer
|
|
77
|
-
//This trap is a bit hackish
|
|
78
|
-
//The next step to improve the node behavior here is to have
|
|
79
|
-
// the compiler generated process method throw a more explicit
|
|
80
|
-
// error when the network buffer is empty (regardles of the
|
|
81
|
-
// protocol/transport stack in use) and replace this heuristic.
|
|
82
|
-
// Also transports should probably not force upper layers to
|
|
83
|
-
// manage their buffer positions (i.e. rollbackPosition() and
|
|
84
|
-
// commitPosition() should be eliminated in lieu of a transport
|
|
85
|
-
// encapsulated buffer management strategy.)
|
|
86
|
-
transportWithData.rollbackPosition();
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
//Unexpected error
|
|
90
|
-
self.emit('error', err);
|
|
91
|
-
stream.end();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}));
|
|
95
|
-
|
|
96
|
-
stream.on('end', function() {
|
|
97
|
-
stream.end();
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (options && options.tls) {
|
|
102
|
-
if (!('secureProtocol' in options.tls) && !('secureOptions' in options.tls)) {
|
|
103
|
-
options.tls.secureProtocol = "SSLv23_method";
|
|
104
|
-
options.tls.secureOptions = constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3;
|
|
105
|
-
}
|
|
106
|
-
return tls.createServer(options.tls, serverImpl);
|
|
107
|
-
} else {
|
|
108
|
-
return net.createServer(serverImpl);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Create a single service Apache Thrift server.
|
|
114
|
-
* @param {object} processor - A service class or processor function.
|
|
115
|
-
* @param {ServerOptions} options - Optional additional server configuration.
|
|
116
|
-
* @returns {object} - The Apache Thrift Multiplex Server.
|
|
117
|
-
*/
|
|
118
|
-
exports.createServer = function(processor, handler, options) {
|
|
119
|
-
if (processor.Processor) {
|
|
120
|
-
processor = processor.Processor;
|
|
121
|
-
}
|
|
122
|
-
return exports.createMultiplexServer(new processor(handler), options);
|
|
123
|
-
};
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
var util = require('util');
|
|
20
|
-
|
|
21
|
-
var Type = exports.Type = {
|
|
22
|
-
STOP: 0,
|
|
23
|
-
VOID: 1,
|
|
24
|
-
BOOL: 2,
|
|
25
|
-
BYTE: 3,
|
|
26
|
-
I08: 3,
|
|
27
|
-
DOUBLE: 4,
|
|
28
|
-
I16: 6,
|
|
29
|
-
I32: 8,
|
|
30
|
-
I64: 10,
|
|
31
|
-
STRING: 11,
|
|
32
|
-
UTF7: 11,
|
|
33
|
-
STRUCT: 12,
|
|
34
|
-
MAP: 13,
|
|
35
|
-
SET: 14,
|
|
36
|
-
LIST: 15,
|
|
37
|
-
UTF8: 16,
|
|
38
|
-
UTF16: 17
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.MessageType = {
|
|
42
|
-
CALL: 1,
|
|
43
|
-
REPLY: 2,
|
|
44
|
-
EXCEPTION: 3,
|
|
45
|
-
ONEWAY: 4
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
exports.TException = TException;
|
|
49
|
-
|
|
50
|
-
function TException(message) {
|
|
51
|
-
Error.call(this);
|
|
52
|
-
if (Error.captureStackTrace !== undefined) {
|
|
53
|
-
Error.captureStackTrace(this, this.constructor);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.name = this.constructor.name;
|
|
57
|
-
this.message = message;
|
|
58
|
-
};
|
|
59
|
-
util.inherits(TException, Error);
|
|
60
|
-
|
|
61
|
-
var TApplicationExceptionType = exports.TApplicationExceptionType = {
|
|
62
|
-
UNKNOWN: 0,
|
|
63
|
-
UNKNOWN_METHOD: 1,
|
|
64
|
-
INVALID_MESSAGE_TYPE: 2,
|
|
65
|
-
WRONG_METHOD_NAME: 3,
|
|
66
|
-
BAD_SEQUENCE_ID: 4,
|
|
67
|
-
MISSING_RESULT: 5,
|
|
68
|
-
INTERNAL_ERROR: 6,
|
|
69
|
-
PROTOCOL_ERROR: 7,
|
|
70
|
-
INVALID_TRANSFORM: 8,
|
|
71
|
-
INVALID_PROTOCOL: 9,
|
|
72
|
-
UNSUPPORTED_CLIENT_TYPE: 10
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.TApplicationException = TApplicationException;
|
|
76
|
-
|
|
77
|
-
function TApplicationException(type, message) {
|
|
78
|
-
TException.call(this);
|
|
79
|
-
if (Error.captureStackTrace !== undefined) {
|
|
80
|
-
Error.captureStackTrace(this, this.constructor);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.type = type || TApplicationExceptionType.UNKNOWN;
|
|
84
|
-
this.name = this.constructor.name;
|
|
85
|
-
this.message = message;
|
|
86
|
-
};
|
|
87
|
-
util.inherits(TApplicationException, TException);
|
|
88
|
-
|
|
89
|
-
TApplicationException.prototype.read = function(input) {
|
|
90
|
-
var ftype;
|
|
91
|
-
var ret = input.readStructBegin('TApplicationException');
|
|
92
|
-
|
|
93
|
-
while(1){
|
|
94
|
-
ret = input.readFieldBegin();
|
|
95
|
-
if(ret.ftype == Type.STOP)
|
|
96
|
-
break;
|
|
97
|
-
|
|
98
|
-
switch(ret.fid){
|
|
99
|
-
case 1:
|
|
100
|
-
if( ret.ftype == Type.STRING ){
|
|
101
|
-
ret = input.readString();
|
|
102
|
-
this.message = ret;
|
|
103
|
-
} else {
|
|
104
|
-
ret = input.skip(ret.ftype);
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case 2:
|
|
108
|
-
if( ret.ftype == Type.I32 ){
|
|
109
|
-
ret = input.readI32();
|
|
110
|
-
this.type = ret;
|
|
111
|
-
} else {
|
|
112
|
-
ret = input.skip(ret.ftype);
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
ret = input.skip(ret.ftype);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
input.readFieldEnd();
|
|
120
|
-
}
|
|
121
|
-
input.readStructEnd();
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
TApplicationException.prototype.write = function(output){
|
|
125
|
-
output.writeStructBegin('TApplicationException');
|
|
126
|
-
|
|
127
|
-
if (this.message) {
|
|
128
|
-
output.writeFieldBegin('message', Type.STRING, 1);
|
|
129
|
-
output.writeString(this.message);
|
|
130
|
-
output.writeFieldEnd();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (this.code) {
|
|
134
|
-
output.writeFieldBegin('type', Type.I32, 2);
|
|
135
|
-
output.writeI32(this.code);
|
|
136
|
-
output.writeFieldEnd();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
output.writeFieldStop();
|
|
140
|
-
output.writeStructEnd();
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
var TProtocolExceptionType = exports.TProtocolExceptionType = {
|
|
144
|
-
UNKNOWN: 0,
|
|
145
|
-
INVALID_DATA: 1,
|
|
146
|
-
NEGATIVE_SIZE: 2,
|
|
147
|
-
SIZE_LIMIT: 3,
|
|
148
|
-
BAD_VERSION: 4,
|
|
149
|
-
NOT_IMPLEMENTED: 5,
|
|
150
|
-
DEPTH_LIMIT: 6
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
exports.TProtocolException = TProtocolException;
|
|
155
|
-
|
|
156
|
-
function TProtocolException(type, message) {
|
|
157
|
-
Error.call(this);
|
|
158
|
-
if (Error.captureStackTrace !== undefined) {
|
|
159
|
-
Error.captureStackTrace(this, this.constructor);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.name = this.constructor.name;
|
|
163
|
-
this.type = type;
|
|
164
|
-
this.message = message;
|
|
165
|
-
};
|
|
166
|
-
util.inherits(TProtocolException, Error);
|
|
167
|
-
|
|
168
|
-
exports.objectLength = function(obj) {
|
|
169
|
-
return Object.keys(obj).length;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
exports.inherits = function(constructor, superConstructor) {
|
|
173
|
-
util.inherits(constructor, superConstructor);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
var copyList, copyMap;
|
|
177
|
-
|
|
178
|
-
copyList = function(lst, types) {
|
|
179
|
-
|
|
180
|
-
if (!lst) {return lst; }
|
|
181
|
-
|
|
182
|
-
var type;
|
|
183
|
-
|
|
184
|
-
if (types.shift === undefined) {
|
|
185
|
-
type = types;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
type = types[0];
|
|
189
|
-
}
|
|
190
|
-
var Type = type;
|
|
191
|
-
|
|
192
|
-
var len = lst.length, result = [], i, val;
|
|
193
|
-
for (i = 0; i < len; i++) {
|
|
194
|
-
val = lst[i];
|
|
195
|
-
if (type === null) {
|
|
196
|
-
result.push(val);
|
|
197
|
-
}
|
|
198
|
-
else if (type === copyMap || type === copyList) {
|
|
199
|
-
result.push(type(val, types.slice(1)));
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
result.push(new Type(val));
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return result;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
copyMap = function(obj, types){
|
|
209
|
-
|
|
210
|
-
if (!obj) {return obj; }
|
|
211
|
-
|
|
212
|
-
var type;
|
|
213
|
-
|
|
214
|
-
if (types.shift === undefined) {
|
|
215
|
-
type = types;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
type = types[0];
|
|
219
|
-
}
|
|
220
|
-
var Type = type;
|
|
221
|
-
|
|
222
|
-
var result = {}, val;
|
|
223
|
-
for(var prop in obj) {
|
|
224
|
-
if(obj.hasOwnProperty(prop)) {
|
|
225
|
-
val = obj[prop];
|
|
226
|
-
if (type === null) {
|
|
227
|
-
result[prop] = val;
|
|
228
|
-
}
|
|
229
|
-
else if (type === copyMap || type === copyList) {
|
|
230
|
-
result[prop] = type(val, types.slice(1));
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
result[prop] = new Type(val);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return result;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
module.exports.copyMap = copyMap;
|
|
241
|
-
module.exports.copyList = copyList;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
|
4
|
-
* distributed with this work for additional information
|
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
|
7
|
-
* "License"); you may not use this file except in compliance
|
|
8
|
-
* with the License. You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
module.exports.TBufferedTransport = require('./buffered_transport');
|
|
21
|
-
module.exports.TFramedTransport = require('./framed_transport');
|
|
22
|
-
module.exports.InputBufferUnderrunError = require('./input_buffer_underrun_error');
|