diff --git a/lib/connection.js b/lib/connection.js index 06b36bb..381651b 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -81,12 +81,12 @@ function get_socket_id(socket) { return socket.localAddress + ':' + socket.localPort + ' -> ' + socket.remoteAddress + ':' + socket.remotePort; } -function session_per_connection(conn, buffer_size) { +function session_per_connection(conn, session_buffer_size) { var ssn = null; return { 'get_session' : function () { if (!ssn) { - ssn = conn.create_session(buffer_size); + ssn = conn.create_session(session_buffer_size); ssn.observers.on('session_close', function () { ssn = null; }); ssn.begin(); } @@ -208,7 +208,7 @@ var Connection = function (options, container) { && options.servername === undefined && options.host !== undefined) { this.options.servername = options.host; } - this.buffer_size = options.buffer_size; + this.session_buffer_size = options.session_buffer_size; } else { this.options = get_default_connect_config(); } @@ -233,7 +233,7 @@ var Connection = function (options, container) { this.remote = {}; this.local.open = frames.open(connection_fields(this.options)); this.local.close = frames.close({}); - this.session_policy = session_per_connection(this, this.buffer_size); + this.session_policy = session_per_connection(this, this.session_buffer_size); this.amqp_transport = new Transport(this.options.id, AMQP_PROTOCOL_ID, frames.TYPE_AMQP, this); this.sasl_transport = undefined; this.transport = this.amqp_transport; @@ -682,10 +682,10 @@ Connection.prototype.is_closed = function () { return this.state.is_closed(); }; -Connection.prototype.create_session = function (buffer_size) { +Connection.prototype.create_session = function (session_buffer_size) { var i = 0; while (this.local_channel_map[i]) i++; - var session = new Session(this, i, buffer_size); + var session = new Session(this, i, session_buffer_size); this.local_channel_map[i] = session; return session; }; @@ -791,7 +791,7 @@ Connection.prototype.on_begin = function (frame) { var session; if (frame.performative.remote_channel === null || frame.performative.remote_channel === undefined) { //peer initiated - session = this.create_session(this.buffer_size); + session = this.create_session(this.session_buffer_size); session.local.begin.remote_channel = frame.channel; } else { session = this.local_channel_map[frame.performative.remote_channel]; diff --git a/lib/session.js b/lib/session.js index 42f0c85..0f0d94b 100644 --- a/lib/session.js +++ b/lib/session.js @@ -116,25 +116,25 @@ function write_dispositions(deliveries) { } } -function validate_buffer_size(buffer_size) { - if (buffer_size && Number.isInteger(Number(buffer_size))) { - return Number(buffer_size); +function validate_buffer_size(session_buffer_size) { + if (session_buffer_size && Number.isInteger(Number(session_buffer_size))) { + return Number(session_buffer_size); } return DEFAULT_BUFFER_SIZE; } -function get_buffer_size(buffer_size, type) { - if (!buffer_size) { +function get_buffer_size(session_buffer_size, type) { + if (!session_buffer_size) { return DEFAULT_BUFFER_SIZE; } - if (typeof buffer_size === 'number') { - return validate_buffer_size(buffer_size); + if (typeof session_buffer_size === 'number') { + return validate_buffer_size(session_buffer_size); } - return validate_buffer_size(buffer_size[type]); + return validate_buffer_size(session_buffer_size[type]); } -var Outgoing = function (connection, buffer_size) { - this.deliveries = new CircularBuffer(get_buffer_size(buffer_size, 'outgoing')); +var Outgoing = function (connection, session_buffer_size) { + this.deliveries = new CircularBuffer(get_buffer_size(session_buffer_size, 'outgoing')); this.updated = []; this.pending_dispositions = []; this.next_delivery_id = 0; @@ -303,8 +303,8 @@ Outgoing.prototype.process = function() { this.deliveries.pop_if(function (d) { return d.settled && d.remote_settled; }); }; -var Incoming = function (buffer_size) { - this.deliveries = new CircularBuffer(get_buffer_size(buffer_size, 'incoming')); +var Incoming = function (session_buffer_size) { + this.deliveries = new CircularBuffer(get_buffer_size(session_buffer_size, 'incoming')); this.updated = []; this.next_transfer_id = 0; this.next_delivery_id = undefined; @@ -434,11 +434,11 @@ Incoming.prototype.on_disposition = function (fields) { } }; -var Session = function (connection, local_channel, buffer_size) { +var Session = function (connection, local_channel, session_buffer_size) { this.connection = connection; - this.buffer_size = buffer_size; - this.outgoing = new Outgoing(connection, buffer_size); - this.incoming = new Incoming(buffer_size); + this.session_buffer_size = session_buffer_size; + this.outgoing = new Outgoing(connection, session_buffer_size); + this.incoming = new Incoming(session_buffer_size); this.state = new EndpointState(); this.local = {'channel': local_channel, 'handles':{}}; this.local.begin = frames.begin({next_outgoing_id:this.outgoing.next_transfer_id,incoming_window:this.incoming.window,outgoing_window:this.outgoing.window}); @@ -464,8 +464,8 @@ Session.prototype._disconnect = function() { Session.prototype._reconnect = function() { this.state.reconnect(); - this.outgoing = new Outgoing(this.connection, this.buffer_size); - this.incoming = new Incoming(this.buffer_size); + this.outgoing = new Outgoing(this.connection, this.session_buffer_size); + this.incoming = new Incoming(this.session_buffer_size); this.remote = {'handles':{}}; for (var l in this.links) { this.links[l]._reconnect(); diff --git a/typings/connection.d.ts b/typings/connection.d.ts index 565e98a..22a16e3 100644 --- a/typings/connection.d.ts +++ b/typings/connection.d.ts @@ -94,10 +94,10 @@ interface CommonConnectionOptions extends EndpointOptions { max_frame_size?: number; /** - * @property {number} [buffer_size] The connection sessions outgoing and incoming CircularBuffer size. + * @property {number} [session_buffer_size] The connection sessions outgoing and incoming CircularBuffer size. * Default: 2048 */ - buffer_size?: number | { incoming?: number, outgoing?: number }; + session_buffer_size?: number | { incoming?: number, outgoing?: number }; /** * @property {number} [idle_time_out] The maximum period in milliseconds between activity * (frames) on the connection that is desired from the peer. The open frame carries the