diff --git a/lib/client.js b/lib/client.js index 521596d..917b624 100644 --- a/lib/client.js +++ b/lib/client.js @@ -25,6 +25,7 @@ var EventEmitter = require('events').EventEmitter, util = require('util'), VoltConnection = require('./connection'), VoltConstants = require('./voltconstants'); +const debug = require("debug")("voltdb-client-nodejs:VoltClient"); VoltClient = function(configuration) { EventEmitter.call(this); @@ -35,7 +36,7 @@ VoltClient = function(configuration) { this._getConnections = this.connect.bind(this); this.call = this.call.bind(this); this.callProcedure = this.callProcedure.bind(this); - this.exit = this.connect.bind(this); + this.exit = this.exit.bind(this); this.connectionStats = this.connectionStats.bind(this); this._connectListener = this._connectListener.bind(this); @@ -67,7 +68,9 @@ VoltClient.prototype.connect = function(callback) { con.on(VoltConstants.SESSION_EVENT.QUERY_RESPONSE_ERROR,this._queryResponseErrorListener); con.on(VoltConstants.SESSION_EVENT.QUERY_DISPATCH_ERROR,this._queryDispatchErrorListener); con.on(VoltConstants.SESSION_EVENT.FATAL_ERROR,this._fatalErrorListener); - + + this._connections.push(con); + con.connect(); } } @@ -117,6 +120,16 @@ VoltClient.prototype.call = function(query, readCallback, writeCallback) { } VoltClient.prototype.exit = function(callback) { + + debug("Exiting | Connections Length: %o", this._connections.length); + + for(var i=0;i