Skip to content

Commit

Permalink
Improve handling and configuration of GenerateFederatedSearchIndex job
Browse files Browse the repository at this point in the history
If the default queue was congested, the job would not be run within
1 hour. When the "fetch index" request came from another instance,
it would attempt to generate the index synchronously because the
index was not there in the cache. This failed because generating the
index took longer than the 30 s request timeout.

Now the job is dispatched 30 min before the requests should arrive.
Also, the job can be pushed to a higher priority queue.
  • Loading branch information
mzur committed Nov 29, 2023
1 parent 19311de commit 7b5903f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ protected function schedule(Schedule $schedule): void
$schedule
->call(function () {
if (FederatedSearchInstance::withLocalToken()->exists()) {
GenerateFederatedSearchIndex::dispatch();
GenerateFederatedSearchIndex::dispatch()
->onQueue(config('biigle.federated_search.index_queue'));
}
})
->name('generate-federated-search-index')
// The requests to retrieve the federated search index are sent hourly at 05.
// This should not collide with this job to generate the index.
->hourlyAt(55)
->hourlyAt(35)
->onOneServer();

$schedule
Expand Down
5 changes: 5 additions & 0 deletions config/biigle.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
| Cache key to use for the federated search index.
*/
'cache_key' => env('BIIGLE_FEDERATED_SEARCH_CACHE_KEY', 'federated_search_index'),

/*
| The queue to submit the "generate federated search index" job to.
*/
'index_queue' => env('BIIGLE_FEDERATED_SEARCH_INDEX_QUEUE', 'default'),
],

];

0 comments on commit 7b5903f

Please sign in to comment.