diff --git a/src/Console/Commands/ImportCommand.php b/src/Console/Commands/ImportCommand.php index d67a9099..fbdf0675 100644 --- a/src/Console/Commands/ImportCommand.php +++ b/src/Console/Commands/ImportCommand.php @@ -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; @@ -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(); diff --git a/src/ElasticSearch/Config/Config.php b/src/ElasticSearch/Config/Config.php index f892eefd..93817fed 100644 --- a/src/ElasticSearch/Config/Config.php +++ b/src/ElasticSearch/Config/Config.php @@ -8,6 +8,7 @@ * @method static password() * @method static elasticCloudId() * @method static apiKey() + * @method static queueTimeout() */ class Config { diff --git a/src/ElasticSearch/Config/Storage.php b/src/ElasticSearch/Config/Storage.php index d583c5c9..87abf2d4 100644 --- a/src/ElasticSearch/Config/Storage.php +++ b/src/ElasticSearch/Config/Storage.php @@ -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