Skip to content

Commit

Permalink
queueTimeout config moved to Config/Storage::class with nullable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hkulekci committed Feb 12, 2023
1 parent e32007f commit 292f852
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Console/Commands/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Matchish\ScoutElasticSearch\ElasticSearch\Config\Config;
use Matchish\ScoutElasticSearch\Jobs\Import;
use Matchish\ScoutElasticSearch\Jobs\QueueableJob;
use Matchish\ScoutElasticSearch\Searchable\ImportSource;
Expand Down Expand Up @@ -48,11 +49,11 @@ private function import(string $searchable): void
$sourceFactory = app(ImportSourceFactory::class);
$source = $sourceFactory::from($searchable);
$job = new Import($source);
$job->timeout = config('elasticsearch.queue.timeout');
$job->timeout = Config::queueTimeout();

if (config('scout.queue')) {
$job = (new QueueableJob())->chain([$job]);
$job->timeout = config('elasticsearch.queue.timeout');
$job->timeout = Config::queueTimeout();
}

$bar = (new ProgressBarFactory($this->output))->create();
Expand Down
1 change: 1 addition & 0 deletions src/ElasticSearch/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @method static password()
* @method static elasticCloudId()
* @method static apiKey()
* @method static queueTimeout()
*/
class Config
{
Expand Down
8 changes: 8 additions & 0 deletions src/ElasticSearch/Config/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public function apiKey(): ?string
return $this->loadConfig('api_key');
}

/**
* @return ?int
*/
public function queueTimeout(): ?int
{
return (int) $this->loadConfig('queue.timeout') ?: null;
}

/**
* @param string $path
* @return mixed
Expand Down

0 comments on commit 292f852

Please sign in to comment.