From d06ee7c558864f145f787d5bb0dcb0d042e26c3b Mon Sep 17 00:00:00 2001 From: Pete Freitag Date: Mon, 16 Dec 2024 10:19:35 -0500 Subject: [PATCH] Add FIXINATOR_MAX_CONCURRENCY setting --- README.md | 11 +++++++++++ box.json | 4 ++-- commands/fixinator.cfc | 4 ++++ models/fixinator/FixinatorClient.cfc | 23 ++++++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 390e5eb..e0e3871 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,17 @@ You can also set this value by running: This variable should only be used with the enterprise edition. +### FIXINATOR_MAX_CONCURRENCY `ENTERPRISE EDITION` + +The `FIXINATOR_MAX_CONCURRENCY` environment variable specifies the maximum number of +threads to use + +You can also set this value by running: + + box config set modules.fixinator.max_concurrency=8 + +The default value is `8` + ## .fixinator.json A `.fixinator.json` configuration file can be placed in the root of a folder to be scanned. For Example: diff --git a/box.json b/box.json index 3a2033c..cd85c98 100644 --- a/box.json +++ b/box.json @@ -1,8 +1,8 @@ { "name":"fixinator", - "version":"5.0.0", + "version":"5.0.1", "author":"Foundeo Inc.", - "location":"foundeo/fixinator#v5.0.0", + "location":"foundeo/fixinator#v5.0.1", "homepage":"https://fixinator.app/", "documentation":"https://github.com/foundeo/fixinator/wiki", "repository":{ diff --git a/commands/fixinator.cfc b/commands/fixinator.cfc index 8c1e1da..e680265 100644 --- a/commands/fixinator.cfc +++ b/commands/fixinator.cfc @@ -178,6 +178,10 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false { fixinatorClient.setAPITimeout(configService.getSetting("modules.fixinator.api_timeout", "35")); } + if (configService.getSetting("modules.fixinator.max_concurrency", "UNDEFINED") != "UNDEFINED") { + fixinatorClient.setMaxConcurrency(configService.getSetting("modules.fixinator.max_concurrency", "8")); + } + if (arguments.verbose) { print.greenLine("Fixinator API Server: #fixinatorClient.getAPIURL()#"); } diff --git a/models/fixinator/FixinatorClient.cfc b/models/fixinator/FixinatorClient.cfc index 95cd0db..9eae972 100644 --- a/models/fixinator/FixinatorClient.cfc +++ b/models/fixinator/FixinatorClient.cfc @@ -21,6 +21,11 @@ component singleton="true" { variables.apiTimeout = trim(variables.system.getenv("FIXINATOR_API_TIMEOUT")); } + variables.maxConcurrency = 8; + if (!isNull(variables.system.getenv("FIXINATOR_MAX_CONCURRENCY"))) { + variables.maxConcurrency = trim(variables.system.getenv("FIXINATOR_MAX_CONCURRENCY")); + } + variables.clientUpdate = false; variables.debugMode = false; @@ -138,7 +143,15 @@ component singleton="true" { } if (server.keyExists("lucee")) { //run parallel on lucee - arrayEach(local.batches, processBatch, true, arrayLen(local.batches)); + local.concurrency = arrayLen(local.batches); + if (local.concurrency > variables.maxConcurrency) { + local.concurrency = variables.maxConcurrency; + } + //use at least 2 threads, to allow progressbar to update + if (hasProgressBar && local.concurrency < 2) { + local.concurrency = 2; + } + arrayEach(local.batches, processBatch, true, local.concurrency); } else { arrayEach(local.batches, processBatch); } @@ -204,6 +217,14 @@ component singleton="true" { variables.apiTimeout = arguments.apiTimeout; } + public function getMaxConcurrency() { + return variables.maxConcurrency; + } + + public function setMaxConcurrency(numeric maxConcurrency) { + variables.maxConcurrency = arguments.maxConcurrency; + } + public function getLockTimeout() { return getAPITimeout() + 1; }