From 28394af7070ac85b51a2d7d4994f9e4526eed523 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Fri, 18 Jul 2014 23:36:36 +0300 Subject: [PATCH] Added an option to configure the number of parameters per request in GetParameterValues and SetParameterValues methods. --- lib/config.coffee | 1 + lib/tasks.coffee | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/config.coffee b/lib/config.coffee index cb90905..f7a5be5 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -39,6 +39,7 @@ exports.IGNORE_XML_NAMESPACES = false # Traverse XML using element's local name exports.LIBXMLJS_OPTIONS = {} # Options passed directly to libxmljs exports.SESSION_TIMEOUT = 30 exports.GET_PARAMETER_NAMES_DEPTH_THRESHOLD = 0 +exports.TASK_PARAMETERS_BATCH_SIZE = 32 exports.MONGODB_OPTIONS = { db : { diff --git a/lib/tasks.coffee b/lib/tasks.coffee index ef595a9..6a3c919 100644 --- a/lib/tasks.coffee +++ b/lib/tasks.coffee @@ -43,7 +43,6 @@ common = require './common' db = require './db' mongodb = require 'mongodb' customCommands = require './custom-commands' -BATCH_SIZE = 16 exports.STATUS_OK = STATUS_OK = 1 exports.STATUS_FAULT = STATUS_FAULT = 2 @@ -156,7 +155,7 @@ this.getParameterValues = (task, methodResponse, callback) -> else if methodResponse.parameterList? task.session.currentIndex = task.session.nextIndex - task.session.nextIndex = Math.min(task.session.currentIndex + BATCH_SIZE, task.parameterNames.length) + task.session.nextIndex = Math.min(task.session.currentIndex + config.TASK_PARAMETERS_BATCH_SIZE, task.parameterNames.length) names = task.parameterNames.slice(task.session.currentIndex, task.session.nextIndex) if methodResponse.type is 'GetParameterValuesResponse' @@ -186,7 +185,7 @@ this.setParameterValues = (task, methodResponse, callback) -> prevValues = task.parameterValues.slice(task.session.currentIndex, task.session.nextIndex) task.session.currentIndex = task.session.nextIndex - task.session.nextIndex = Math.min(task.session.currentIndex + BATCH_SIZE, task.parameterValues.length) + task.session.nextIndex = Math.min(task.session.currentIndex + config.TASK_PARAMETERS_BATCH_SIZE, task.parameterValues.length) values = task.parameterValues.slice(task.session.currentIndex, task.session.nextIndex) if prevValues?