Rename some config options
Original names are still supported for compatibility.
This commit is contained in:
1 parent
848894d3e3
commit
38e83d8544
3 files changed
+34
-18
No files matched your search
+22
-3
@@ -49,13 +49,13 @@ options = {
|
|||||||
|
|
||||||
DOWNLOAD_TIMEOUT: {type : 'int', default : 3600},
|
DOWNLOAD_TIMEOUT: {type : 'int', default : 3600},
|
||||||
EXT_TIMEOUT: {type: 'int', default: 3000},
|
EXT_TIMEOUT: {type: 'int', default: 3000},
|
||||||
PRESETS_CACHE_DURATION : {type : 'int', default : 86400},
|
MAX_CACHE_TTL : {type : 'int', default : 86400},
|
||||||
DEBUG : {type : 'bool', default : false},
|
DEBUG : {type : 'bool', default : false},
|
||||||
RETRY_DELAY : {type : 'int', default : 300},
|
RETRY_DELAY : {type : 'int', default : 300},
|
||||||
SESSION_TIMEOUT : {type : 'int', default : 30},
|
SESSION_TIMEOUT : {type : 'int', default : 30},
|
||||||
CONNECTION_REQUEST_TIMEOUT : {type : 'int', default: 2000},
|
CONNECTION_REQUEST_TIMEOUT : {type : 'int', default: 2000},
|
||||||
GET_PARAMETER_NAMES_DEPTH_THRESHOLD : {type : 'int', default : 0},
|
GPN_NEXT_LEVEL : {type : 'int', default : 0},
|
||||||
TASK_PARAMETERS_BATCH_SIZE : {type : 'int', default : 32},
|
GPV_BATCH_SIZE : {type : 'int', default : 32},
|
||||||
MAX_DEPTH : {type: 'int', default : 16},
|
MAX_DEPTH : {type: 'int', default : 16},
|
||||||
COOKIES_PATH : {type : 'string'},
|
COOKIES_PATH : {type : 'string'},
|
||||||
LOG_FORMAT : {type : 'string', default : 'simple'},
|
LOG_FORMAT : {type : 'string', default : 'simple'},
|
||||||
@@ -79,6 +79,25 @@ allConfig = {}
|
|||||||
setConfig = (name, value, commandLineArgument) ->
|
setConfig = (name, value, commandLineArgument) ->
|
||||||
return true if allConfig[name]?
|
return true if allConfig[name]?
|
||||||
|
|
||||||
|
# For compatibility with v1.0
|
||||||
|
if name in ['PRESETS_CACHE_DURATION', 'presets-cache-duration']
|
||||||
|
setConfig('MAX_CACHE_TTL', value)
|
||||||
|
|
||||||
|
if name in ['GET_PARAMETER_NAMES_DEPTH_THRESHOLD', 'get-parameter-names-depth-threshold']
|
||||||
|
setConfig('GPN_NEXT_LEVEL', value)
|
||||||
|
|
||||||
|
if name in ['TASK_PARAMETERS_BATCH_SIZE', 'task-parameters-batch-size']
|
||||||
|
setConfig('GPV_BATCH_SIZE', value)
|
||||||
|
|
||||||
|
if name in ['IGNORE_XML_NAMESPACES', 'ignore-xml-namespaces']
|
||||||
|
setConfig('XML_IGNORE_NAMESPACE', value)
|
||||||
|
|
||||||
|
if name in ['XML_PARSE_IGNORE_ENC', 'xml-parse-ignore-enc']
|
||||||
|
setConfig('XML_IGNORE_ENC', value)
|
||||||
|
|
||||||
|
if name in ['XML_PARSE_RECOVER', 'xml-parse-recover']
|
||||||
|
setConfig('XML_RECOVER', value)
|
||||||
|
|
||||||
cast = (val, type) ->
|
cast = (val, type) ->
|
||||||
switch type
|
switch type
|
||||||
when 'int'
|
when 'int'
|
||||||
|
|||||||
+6
-6
@@ -466,7 +466,7 @@ getDueTasksAndFaultsAndOperations = (deviceId, timestamp, callback) ->
|
|||||||
if tasks? and faults? and operations?
|
if tasks? and faults? and operations?
|
||||||
return callback(null, tasks, faults, operations)
|
return callback(null, tasks, faults, operations)
|
||||||
|
|
||||||
CACHE_DURATION = config.get('PRESETS_CACHE_DURATION', deviceId)
|
MAX_CACHE_TTL = config.get('MAX_CACHE_TTL', deviceId)
|
||||||
|
|
||||||
if not faults?
|
if not faults?
|
||||||
getFaults(deviceId, (err, flts) ->
|
getFaults(deviceId, (err, flts) ->
|
||||||
@@ -488,7 +488,7 @@ getDueTasksAndFaultsAndOperations = (deviceId, timestamp, callback) ->
|
|||||||
if nextTimestamp?
|
if nextTimestamp?
|
||||||
exp = Math.min(0, Math.trunc((nextTimestamp - Date.now()) / 1000))
|
exp = Math.min(0, Math.trunc((nextTimestamp - Date.now()) / 1000))
|
||||||
else
|
else
|
||||||
exp = CACHE_DURATION
|
exp = MAX_CACHE_TTL
|
||||||
|
|
||||||
redisClient.setex("#{deviceId}_tasks", exp, JSON.stringify(dueTasks), (err) ->
|
redisClient.setex("#{deviceId}_tasks", exp, JSON.stringify(dueTasks), (err) ->
|
||||||
if err
|
if err
|
||||||
@@ -529,9 +529,9 @@ getFaults = (deviceId, callback) ->
|
|||||||
r.provisions = JSON.parse(r.provisions)
|
r.provisions = JSON.parse(r.provisions)
|
||||||
faults[channel] = r
|
faults[channel] = r
|
||||||
|
|
||||||
CACHE_DURATION = config.get('PRESETS_CACHE_DURATION', deviceId)
|
MAX_CACHE_TTL = config.get('MAX_CACHE_TTL', deviceId)
|
||||||
|
|
||||||
redisClient.setex("#{deviceId}_faults", CACHE_DURATION, JSON.stringify(faults), (err) ->
|
redisClient.setex("#{deviceId}_faults", MAX_CACHE_TTL, JSON.stringify(faults), (err) ->
|
||||||
callback(err, faults)
|
callback(err, faults)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -620,9 +620,9 @@ getOperations = (deviceId, callback) ->
|
|||||||
r.retries = JSON.parse(r.retries)
|
r.retries = JSON.parse(r.retries)
|
||||||
operations[commandKey] = r
|
operations[commandKey] = r
|
||||||
|
|
||||||
CACHE_DURATION = config.get('PRESETS_CACHE_DURATION', deviceId)
|
MAX_CACHE_TTL = config.get('MAX_CACHE_TTL', deviceId)
|
||||||
|
|
||||||
redisClient.setex("#{deviceId}_operations", CACHE_DURATION, JSON.stringify(operations), (err) ->
|
redisClient.setex("#{deviceId}_operations", MAX_CACHE_TTL, JSON.stringify(operations), (err) ->
|
||||||
callback(err, operations)
|
callback(err, operations)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+6
-9
@@ -873,8 +873,7 @@ generateGetRpcRequest = (sessionContext) ->
|
|||||||
syncState.refreshAttributes.writable.clear()
|
syncState.refreshAttributes.writable.clear()
|
||||||
|
|
||||||
if syncState.gpn.size
|
if syncState.gpn.size
|
||||||
GET_PARAMETER_NAMES_DEPTH_THRESHOLD =
|
GPN_NEXT_LEVEL = config.get('GPN_NEXT_LEVEL', sessionContext.deviceId)
|
||||||
config.get('GET_PARAMETER_NAMES_DEPTH_THRESHOLD', sessionContext.deviceId)
|
|
||||||
|
|
||||||
paths = Array.from(syncState.gpn.keys()).sort((a,b) -> b.length - a.length)
|
paths = Array.from(syncState.gpn.keys()).sort((a,b) -> b.length - a.length)
|
||||||
path = paths.pop()
|
path = paths.pop()
|
||||||
@@ -888,7 +887,7 @@ generateGetRpcRequest = (sessionContext) ->
|
|||||||
if v = syncState.gpnPatterns.get(p)
|
if v = syncState.gpnPatterns.get(p)
|
||||||
patterns.push([p, (v >> path.length) << path.length])
|
patterns.push([p, (v >> path.length) << path.length])
|
||||||
|
|
||||||
if path.length >= GET_PARAMETER_NAMES_DEPTH_THRESHOLD
|
if path.length >= GPN_NEXT_LEVEL
|
||||||
est = estimateGpnCount(patterns)
|
est = estimateGpnCount(patterns)
|
||||||
else
|
else
|
||||||
est = 0
|
est = 0
|
||||||
@@ -908,13 +907,12 @@ generateGetRpcRequest = (sessionContext) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
if syncState.refreshAttributes.value.size
|
if syncState.refreshAttributes.value.size
|
||||||
TASK_PARAMETERS_BATCH_SIZE =
|
GPV_BATCH_SIZE = config.get('GPV_BATCH_SIZE', sessionContext.deviceId)
|
||||||
config.get('TASK_PARAMETERS_BATCH_SIZE', sessionContext.deviceId)
|
|
||||||
|
|
||||||
parameterNames = []
|
parameterNames = []
|
||||||
iter = syncState.refreshAttributes.value.values()
|
iter = syncState.refreshAttributes.value.values()
|
||||||
while (path = iter.next().value) and
|
while (path = iter.next().value) and
|
||||||
parameterNames.length < TASK_PARAMETERS_BATCH_SIZE
|
parameterNames.length < GPV_BATCH_SIZE
|
||||||
syncState.refreshAttributes.value.delete(path)
|
syncState.refreshAttributes.value.delete(path)
|
||||||
if sessionContext.deviceData.attributes.has(path)
|
if sessionContext.deviceData.attributes.has(path)
|
||||||
parameterNames.push(path)
|
parameterNames.push(path)
|
||||||
@@ -957,12 +955,11 @@ generateSetRpcRequest = (sessionContext) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Set values
|
# Set values
|
||||||
TASK_PARAMETERS_BATCH_SIZE =
|
GPV_BATCH_SIZE = config.get('GPV_BATCH_SIZE', sessionContext.deviceId)
|
||||||
config.get('TASK_PARAMETERS_BATCH_SIZE', sessionContext.deviceId)
|
|
||||||
|
|
||||||
parameterValues = []
|
parameterValues = []
|
||||||
syncState.spv.forEach((v, k) ->
|
syncState.spv.forEach((v, k) ->
|
||||||
return if parameterValues.length >= TASK_PARAMETERS_BATCH_SIZE
|
return if parameterValues.length >= GPV_BATCH_SIZE
|
||||||
attrs = sessionContext.deviceData.attributes.get(k)
|
attrs = sessionContext.deviceData.attributes.get(k)
|
||||||
if (curVal = attrs.value?[1])? and attrs.writable?[1]
|
if (curVal = attrs.value?[1])? and attrs.writable?[1]
|
||||||
val = v.slice()
|
val = v.slice()
|
||||||
|
|||||||
Reference in new issue
Block a user