18 - Changing all hostname to host, fixing some async issues in tests

This commit is contained in:
Nicolas Dextraze
2017-01-28 18:04:58 -08:00
parent f97b7fff8e
commit 006b5b4791
29 changed files with 246 additions and 90 deletions

View File

@ -134,7 +134,6 @@ ClusterDnsEndPointDiscoverer.prototype._getGossipCandidatesFromDns = function ()
ClusterDnsEndPointDiscoverer.prototype._tryGetGossipFrom = function (endPoint) {
var options = {
host: endPoint.endPoint.host,
hostname: endPoint.endPoint.hostname,
port: endPoint.endPoint.port,
path: '/gossip?format=json'
};

View File

@ -30,17 +30,20 @@ OperationsManager.prototype.getActiveOperation = function(correlationId) {
return this._activeOperations.get(correlationId);
};
OperationsManager.prototype.cleanUp = function() {
var connectionClosedError = new Error(util.format("Connection '%s' was closed.", this._connectionName));
function cleanUpError(connName, state, operation) {
return new Error(util.format("Connection '%s' was closed. %s %s.", connName, state, operation.toString()));
}
OperationsManager.prototype.cleanUp = function() {
var self = this;
this._activeOperations.forEach(function(correlationId, operation){
operation.operation.fail(connectionClosedError);
operation.operation.fail(cleanUpError(self._connectionName, 'Active', operation));
});
this._waitingOperations.forEach(function(operation) {
operation.operation.fail(connectionClosedError);
operation.operation.fail(cleanUpError(self._connectionName, 'Waiting', operation));
});
this._retryPendingOperations.forEach(function(operation) {
operation.operation.fail(connectionClosedError);
operation.operation.fail(cleanUpError(self._connectionName, 'Pending', operation));
});
this._activeOperations.clear();

View File

@ -49,7 +49,7 @@ function merge(a,b) {
}
function createFromTcpEndpoint(settings, tcpEndpoint, connectionName) {
if (!tcpEndpoint.port || !tcpEndpoint.hostname) throw new TypeError('endPoint object must have hostname and port properties.');
if (!tcpEndpoint.port || !tcpEndpoint.host) throw new TypeError('endPoint object must have host and port properties.');
var mergedSettings = merge(defaultConnectionSettings, settings || {});
var endpointDiscoverer = new StaticEndpointDiscoverer(tcpEndpoint, settings.useSslConnection);
return new EventStoreNodeConnection(mergedSettings, null, endpointDiscoverer, connectionName || null);
@ -59,11 +59,11 @@ function createFromStringEndpoint(settings, endPoint, connectionName) {
var m = endPoint.match(/^(tcp|discover):\/\/([^:]+):?(\d+)?$/);
if (!m) throw new Error('endPoint string must be tcp://hostname[:port] or discover://dns[:port]');
var scheme = m[1];
var hostname = m[2];
var host = m[2];
var port = m[3] ? parseInt(m[3]) : 1113;
if (scheme === 'tcp') {
var tcpEndpoint = {
hostname: hostname,
host: host,
port: port
};
return createFromTcpEndpoint(settings, tcpEndpoint, connectionName);

View File

@ -1,5 +1,5 @@
module.exports = function GossipSeed(endPoint, hostName) {
//if (typeof endPoint !== 'object' || !endPoint.hostname || !endPoint.port) throw new TypeError('endPoint must be have hostname and port properties.');
if (typeof endPoint !== 'object' || !endPoint.host || !endPoint.port) throw new TypeError('endPoint must be have host and port properties.');
Object.defineProperties(this, {
endPoint: {
enumerable: true,

View File

@ -136,7 +136,7 @@ TcpConnection.createConnectingConnection = function(
onConnectionEstablished, onConnectionFailed, onConnectionClosed
) {
var connection = new TcpConnection(log, connectionId, remoteEndPoint, onConnectionClosed);
var socket = net.connect(remoteEndPoint.port, remoteEndPoint.hostname);
var socket = net.connect(remoteEndPoint.port, remoteEndPoint.host);
function onError(err) {
if (onConnectionFailed)
onConnectionFailed(connection, err);