neo4j-driver-bolt-connection
Advanced tools
Comparing version 5.12.0 to 5.13.0
@@ -405,2 +405,21 @@ "use strict"; | ||
}; | ||
/** | ||
* Send a TELEMETRY through the underlying connection. | ||
* | ||
* @param {object} param0 Message params | ||
* @param {number} param0.api The API called | ||
* @param {object} param1 Configuration and callbacks | ||
* @param {function()} param1.onCompleted Called when completed | ||
* @param {function()} param1.onError Called when error | ||
* @return {StreamObserver} the stream observer that monitors the corresponding server response. | ||
*/ | ||
BoltProtocol.prototype.telemetry = function (_a, _b) { | ||
var api = _a.api; | ||
var _c = _b === void 0 ? {} : _b, onError = _c.onError, onCompleted = _c.onCompleted; | ||
var observer = new stream_observers_1.CompletedObserver(); | ||
if (onCompleted) { | ||
onCompleted(); | ||
} | ||
return observer; | ||
}; | ||
BoltProtocol.prototype._createPacker = function (chunker) { | ||
@@ -407,0 +426,0 @@ return new packstream_1.v1.Packer(chunker); |
@@ -37,2 +37,3 @@ "use strict"; | ||
var bolt_protocol_v5x3_1 = __importDefault(require("./bolt-protocol-v5x3")); | ||
var bolt_protocol_v5x4_1 = __importDefault(require("./bolt-protocol-v5x4")); | ||
// eslint-disable-next-line no-unused-vars | ||
@@ -108,2 +109,4 @@ var channel_1 = require("../channel"); | ||
return new bolt_protocol_v5x3_1.default(server, chunker, packingConfig, createResponseHandler, log, onProtocolError, serversideRouting); | ||
case 5.4: | ||
return new bolt_protocol_v5x4_1.default(server, chunker, packingConfig, createResponseHandler, log, onProtocolError, serversideRouting); | ||
default: | ||
@@ -110,0 +113,0 @@ throw (0, neo4j_driver_core_1.newError)('Unknown Bolt protocol version: ' + version); |
@@ -71,3 +71,3 @@ "use strict"; | ||
return createHandshakeMessage([ | ||
[version(5, 3), version(5, 0)], | ||
[version(5, 4), version(5, 0)], | ||
[version(4, 4), version(4, 2)], | ||
@@ -74,0 +74,0 @@ version(4, 1), |
@@ -37,2 +37,3 @@ "use strict"; | ||
var ROLLBACK = 0x13; // 0001 0011 // ROLLBACK | ||
var TELEMETRY = 0x54; // 0101 0100 // TELEMETRY <api> | ||
var ROUTE = 0x66; // 0110 0110 // ROUTE | ||
@@ -56,2 +57,3 @@ var LOGON = 0x6A; // LOGON | ||
ROLLBACK: ROLLBACK, | ||
TELEMETRY: TELEMETRY, | ||
ROUTE: ROUTE, | ||
@@ -288,2 +290,7 @@ LOGON: LOGON, | ||
}; | ||
RequestMessage.telemetry = function (_a) { | ||
var api = _a.api; | ||
var parsedApi = (0, neo4j_driver_core_1.int)(api); | ||
return new RequestMessage(TELEMETRY, [parsedApi], function () { return "TELEMETRY ".concat(parsedApi.toString()); }); | ||
}; | ||
/** | ||
@@ -290,0 +297,0 @@ * Generate the ROUTE message, this message is used to fetch the routing table from the server |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProcedureRouteObserver = exports.RouteObserver = exports.CompletedObserver = exports.FailedObserver = exports.ResetObserver = exports.LogoffObserver = exports.LoginObserver = exports.ResultStreamObserver = exports.StreamObserver = void 0; | ||
exports.TelemetryObserver = exports.ProcedureRouteObserver = exports.RouteObserver = exports.CompletedObserver = exports.FailedObserver = exports.ResetObserver = exports.LogoffObserver = exports.LoginObserver = exports.ResultStreamObserver = exports.StreamObserver = void 0; | ||
/** | ||
@@ -480,2 +480,33 @@ * Copyright (c) "Neo4j" | ||
exports.ResetObserver = ResetObserver; | ||
var TelemetryObserver = /** @class */ (function (_super) { | ||
__extends(TelemetryObserver, _super); | ||
/** | ||
* | ||
* @param {Object} param - | ||
* @param {function(err: Error)} param.onError | ||
* @param {function(metadata)} param.onCompleted | ||
*/ | ||
function TelemetryObserver(_a) { | ||
var _b = _a === void 0 ? {} : _a, onError = _b.onError, onCompleted = _b.onCompleted; | ||
var _this = _super.call(this) || this; | ||
_this._onError = onError; | ||
_this._onCompleted = onCompleted; | ||
return _this; | ||
} | ||
TelemetryObserver.prototype.onNext = function (record) { | ||
this.onError((0, neo4j_driver_core_1.newError)('Received RECORD when sending telemetry ' + neo4j_driver_core_1.json.stringify(record), PROTOCOL_ERROR)); | ||
}; | ||
TelemetryObserver.prototype.onError = function (error) { | ||
if (this._onError) { | ||
this._onError(error); | ||
} | ||
}; | ||
TelemetryObserver.prototype.onCompleted = function (metadata) { | ||
if (this._onCompleted) { | ||
this._onCompleted(metadata); | ||
} | ||
}; | ||
return TelemetryObserver; | ||
}(ResultStreamObserver)); | ||
exports.TelemetryObserver = TelemetryObserver; | ||
var FailedObserver = /** @class */ (function (_super) { | ||
@@ -482,0 +513,0 @@ __extends(FailedObserver, _super); |
@@ -183,3 +183,3 @@ "use strict"; | ||
return this._createChannelConnection(address).then(function (connection) { | ||
connection._release = function () { | ||
connection.release = function () { | ||
return release(address, connection); | ||
@@ -276,3 +276,3 @@ }; | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, connection._release()]; | ||
case 5: return [4 /*yield*/, connection.release()]; | ||
case 6: | ||
@@ -328,3 +328,3 @@ _b.sent(); | ||
throw error_2; | ||
case 9: return [4 /*yield*/, Promise.all(connectionsToRelease.map(function (conn) { return conn._release(); }))]; | ||
case 9: return [4 /*yield*/, Promise.all(connectionsToRelease.map(function (conn) { return conn.release(); }))]; | ||
case 10: | ||
@@ -349,3 +349,3 @@ _b.sent(); | ||
if (!(shouldCreateStickyConnection || connection._sticky)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, connection._release()]; | ||
return [4 /*yield*/, connection.release()]; | ||
case 1: | ||
@@ -352,0 +352,0 @@ _b.sent(); |
@@ -123,3 +123,3 @@ "use strict"; | ||
}; | ||
var connection = new ChannelConnection(channel, errorHandler, address, log, config.disableLosslessIntegers, serversideRouting, chunker, config.notificationFilter, createProtocol); | ||
var connection = new ChannelConnection(channel, errorHandler, address, log, config.disableLosslessIntegers, serversideRouting, chunker, config.notificationFilter, createProtocol, config.telemetryDisabled); | ||
// forward all pending bytes to the dechunker | ||
@@ -149,3 +149,3 @@ consumeRemainingBuffer(function (buffer) { return dechunker.write(buffer); }); | ||
function ChannelConnection(channel, errorHandler, address, log, disableLosslessIntegers, serversideRouting, chunker, // to be removed, | ||
notificationFilter, protocolSupplier) { | ||
notificationFilter, protocolSupplier, telemetryDisabled) { | ||
if (disableLosslessIntegers === void 0) { disableLosslessIntegers = false; } | ||
@@ -167,2 +167,4 @@ if (serversideRouting === void 0) { serversideRouting = null; } | ||
_this._notificationFilter = notificationFilter; | ||
_this._telemetryDisabledDriverConfig = telemetryDisabled === true; | ||
_this._telemetryDisabledConnection = true; | ||
// connection from the database, returned in response for HELLO message and might not be available | ||
@@ -183,2 +185,33 @@ _this._dbConnectionId = null; | ||
} | ||
ChannelConnection.prototype.beginTransaction = function (config) { | ||
this._sendTelemetryIfEnabled(config); | ||
return this._protocol.beginTransaction(config); | ||
}; | ||
ChannelConnection.prototype.run = function (query, parameters, config) { | ||
this._sendTelemetryIfEnabled(config); | ||
return this._protocol.run(query, parameters, config); | ||
}; | ||
ChannelConnection.prototype._sendTelemetryIfEnabled = function (config) { | ||
if (this._telemetryDisabledConnection || | ||
this._telemetryDisabledDriverConfig || | ||
config == null || | ||
config.apiTelemetryConfig == null) { | ||
return; | ||
} | ||
this._protocol.telemetry({ | ||
api: config.apiTelemetryConfig.api | ||
}, { | ||
onCompleted: config.apiTelemetryConfig.onTelemetrySuccess, | ||
onError: config.beforeError | ||
}); | ||
}; | ||
ChannelConnection.prototype.commitTransaction = function (config) { | ||
return this._protocol.commitTransaction(config); | ||
}; | ||
ChannelConnection.prototype.rollbackTransaction = function (config) { | ||
return this._protocol.rollbackTransaction(config); | ||
}; | ||
ChannelConnection.prototype.getProtocolVersion = function () { | ||
return this._protocol.version; | ||
}; | ||
Object.defineProperty(ChannelConnection.prototype, "authToken", { | ||
@@ -304,2 +337,6 @@ get: function () { | ||
} | ||
var telemetryEnabledHint = metadata.hints['telemetry.enabled']; | ||
if (telemetryEnabledHint === true) { | ||
_this._telemetryDisabledConnection = false; | ||
} | ||
} | ||
@@ -306,0 +343,0 @@ } |
@@ -55,2 +55,17 @@ "use strict"; | ||
} | ||
DelegateConnection.prototype.beginTransaction = function (config) { | ||
return this._delegate.beginTransaction(config); | ||
}; | ||
DelegateConnection.prototype.run = function (query, param, config) { | ||
return this._delegate.run(query, param, config); | ||
}; | ||
DelegateConnection.prototype.commitTransaction = function (config) { | ||
return this._delegate.commitTransaction(config); | ||
}; | ||
DelegateConnection.prototype.rollbackTransaction = function (config) { | ||
return this._delegate.rollbackTransaction(config); | ||
}; | ||
DelegateConnection.prototype.getProtocolVersion = function () { | ||
return this._delegate.getProtocolVersion(); | ||
}; | ||
Object.defineProperty(DelegateConnection.prototype, "id", { | ||
@@ -135,7 +150,7 @@ get: function () { | ||
}; | ||
DelegateConnection.prototype._release = function () { | ||
DelegateConnection.prototype.release = function () { | ||
if (this._originalErrorHandler) { | ||
this._delegate._errorHandler = this._originalErrorHandler; | ||
} | ||
return this._delegate._release(); | ||
return this._delegate.release(); | ||
}; | ||
@@ -142,0 +157,0 @@ return DelegateConnection; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -23,3 +38,5 @@ /** | ||
var bolt_1 = require("../bolt"); | ||
var Connection = /** @class */ (function () { | ||
var neo4j_driver_core_1 = require("neo4j-driver-core"); | ||
var Connection = /** @class */ (function (_super) { | ||
__extends(Connection, _super); | ||
/** | ||
@@ -29,3 +46,5 @@ * @param {ConnectionErrorHandler} errorHandler the error handler | ||
function Connection(errorHandler) { | ||
this._errorHandler = errorHandler; | ||
var _this = _super.call(this) || this; | ||
_this._errorHandler = errorHandler; | ||
return _this; | ||
} | ||
@@ -67,8 +86,2 @@ Object.defineProperty(Connection.prototype, "id", { | ||
/** | ||
* @returns {boolean} whether this connection is in a working condition | ||
*/ | ||
Connection.prototype.isOpen = function () { | ||
throw new Error('not implemented'); | ||
}; | ||
/** | ||
* @returns {BoltProtocol} the underlying bolt protocol assigned to this connection | ||
@@ -130,12 +143,2 @@ */ | ||
/** | ||
* Send a RESET-message to the database. Message is immediately flushed to the network. | ||
* @return {Promise<void>} promise resolved when SUCCESS-message response arrives, or failed when other response messages arrives. | ||
*/ | ||
Connection.prototype.resetAndFlush = function () { | ||
throw new Error('not implemented'); | ||
}; | ||
Connection.prototype.hasOngoingObservableRequests = function () { | ||
throw new Error('not implemented'); | ||
}; | ||
/** | ||
* Call close on the channel. | ||
@@ -161,3 +164,3 @@ * @returns {Promise<void>} - A promise that will be resolved when the connection is closed. | ||
return Connection; | ||
}()); | ||
}(neo4j_driver_core_1.Connection)); | ||
exports.default = Connection; |
@@ -311,6 +311,9 @@ "use strict"; | ||
key = address.asKey(); | ||
if (!pool.isActive()) return [3 /*break*/, 5]; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, , 9, 10]); | ||
if (!pool.isActive()) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this._validateOnRelease(resource)]; | ||
case 1: | ||
if (!!(_a.sent())) return [3 /*break*/, 3]; | ||
case 2: | ||
if (!!(_a.sent())) return [3 /*break*/, 4]; | ||
if (this._log.isDebugEnabled()) { | ||
@@ -321,6 +324,6 @@ this._log.debug("".concat(resource, " destroyed and can't be released to the pool ").concat(key, " because it is not functional")); | ||
return [4 /*yield*/, this._destroy(resource)]; | ||
case 2: | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
if (this._installIdleObserver) { | ||
@@ -346,5 +349,5 @@ this._installIdleObserver(resource, { | ||
} | ||
_a.label = 4; | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: | ||
_a.label = 5; | ||
case 5: return [3 /*break*/, 8]; | ||
case 6: | ||
// key has been purged, don't put it back, just destroy the resource | ||
@@ -356,9 +359,11 @@ if (this._log.isDebugEnabled()) { | ||
return [4 /*yield*/, this._destroy(resource)]; | ||
case 6: | ||
case 7: | ||
_a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
_a.label = 8; | ||
case 8: return [3 /*break*/, 10]; | ||
case 9: | ||
resourceReleased(key, this._activeResourceCounts); | ||
this._processPendingAcquireRequests(address); | ||
return [2 /*return*/]; | ||
return [7 /*endfinally*/]; | ||
case 10: return [2 /*return*/]; | ||
} | ||
@@ -365,0 +370,0 @@ }); |
{ | ||
"name": "neo4j-driver-bolt-connection", | ||
"version": "5.12.0", | ||
"version": "5.13.0", | ||
"description": "Implements the connection with the Neo4j Database using the Bolt Protocol", | ||
@@ -43,6 +43,6 @@ "main": "lib/index.js", | ||
"buffer": "^6.0.3", | ||
"neo4j-driver-core": "5.12.0", | ||
"neo4j-driver-core": "5.13.0", | ||
"string_decoder": "^1.3.0" | ||
}, | ||
"gitHead": "90941a7136c2711a2945e0715b3d4a2f38b64ef5" | ||
"gitHead": "4369108abbfc9757efac4b2171b88874b9258ff4" | ||
} |
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
598349
90
12917
+ Addedneo4j-driver-core@5.13.0(transitive)
- Removedneo4j-driver-core@5.12.0(transitive)
Updatedneo4j-driver-core@5.13.0