Skip to content

Commit

Permalink
Merge pull request #17 from kitsunet/feature/configurable-batch-size
Browse files Browse the repository at this point in the history
FEATURE: Make batch size configurable
  • Loading branch information
dfeyer authored Oct 4, 2017
2 parents a1b9ca5 + d7beec6 commit db61678
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Classes/Command/NodeIndexQueueCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class NodeIndexQueueCommandController extends CommandController

const BATCH_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer';
const LIVE_QUEUE_NAME = 'Flowpack.ElasticSearch.ContentRepositoryQueueIndexer.Live';
const DEFAULT_BATCH_SIZE = 500;

/**
* @var JobManager
Expand Down Expand Up @@ -69,6 +70,12 @@ class NodeIndexQueueCommandController extends CommandController
*/
protected $nodeIndexer;

/**
* @Flow\InjectConfiguration(package="Flowpack.ElasticSearch.ContentRepositoryQueueIndexer")
* @var array
*/
protected $settings;

/**
* Index all nodes by creating a new index and when everything was completed, switch the index alias.
*
Expand Down Expand Up @@ -210,7 +217,7 @@ protected function indexWorkspace($workspaceName, $indexPostfix)
$this->outputLine('<info>++</info> Indexing %s workspace', [$workspaceName]);
$nodeCounter = 0;
$offset = 0;
$batchSize = 500;
$batchSize = $this->settings['batchSize'] ?? static::DEFAULT_BATCH_SIZE;
while (true) {
$iterator = $this->nodeDataRepository->findAllBySiteAndWorkspace($workspaceName, $offset, $batchSize);

Expand Down
3 changes: 2 additions & 1 deletion Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Flowpack:
ElasticSearch:
ContentRepositoryQueueIndexer:
enableLiveAsyncIndexing: true

# Change size of single batch jobs via this setting (fallback default is 500)
# batchSize: 50
JobQueue:
Common:
queues:
Expand Down

0 comments on commit db61678

Please sign in to comment.