Skip to content

Commit 9cc45ed

Browse files
committed
TASK: Improve batch size settings handling
Instead of using a class constant and programmatic fallback handling, simply define the default using `Settings.yaml`.
1 parent 44c9b74 commit 9cc45ed

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Classes/Command/NodeIndexQueueCommandController.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class NodeIndexQueueCommandController extends CommandController
2828

2929
const BATCH_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer';
3030
const LIVE_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live';
31-
const DEFAULT_BATCH_SIZE = 500;
3231

3332
/**
3433
* @var JobManager
@@ -73,10 +72,10 @@ class NodeIndexQueueCommandController extends CommandController
7372
protected $nodeIndexer;
7473

7574
/**
76-
* @Flow\InjectConfiguration(package="Flowpack.ElasticSearch.ContentRepositoryQueueIndexer")
77-
* @var array
75+
* @Flow\InjectConfiguration(path="batchSize")
76+
* @var int
7877
*/
79-
protected $settings;
78+
protected $batchSize;
8079

8180
/**
8281
* Index all nodes by creating a new index and when everything was completed, switch the index alias.
@@ -228,9 +227,8 @@ protected function indexWorkspace($workspaceName, $indexPostfix)
228227
$this->outputLine('<info>++</info> Indexing %s workspace', [$workspaceName]);
229228
$nodeCounter = 0;
230229
$offset = 0;
231-
$batchSize = $this->settings['batchSize'] ?? static::DEFAULT_BATCH_SIZE;
232230
while (true) {
233-
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $batchSize);
231+
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $this->batchSize);
234232

235233
$jobData = [];
236234

@@ -252,7 +250,7 @@ protected function indexWorkspace($workspaceName, $indexPostfix)
252250
$indexingJob = new IndexingJob($indexPostfix, $workspaceName, $jobData);
253251
$this->jobManager->queue(self::BATCH_QUEUE_NAME, $indexingJob);
254252
$this->output('.');
255-
$offset += $batchSize;
253+
$offset += $this->batchSize;
256254
$this->persistenceManager->clearState();
257255
}
258256
$this->outputLine();

Configuration/Settings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Flowpack:
22
ElasticSearch:
33
ContentRepositoryQueueIndexer:
44
enableLiveAsyncIndexing: true
5-
# Change size of single batch jobs via this setting (fallback default is 500)
6-
# batchSize: 50
5+
# Change size of single batch jobs via this setting
6+
batchSize: 500
77
JobQueue:
88
Common:
99
queues:

0 commit comments

Comments
 (0)