Skip to content

Commit

Permalink
Merge pull request #6 from Escavador/fix_job_failed_warning
Browse files Browse the repository at this point in the history
Update the job failed warning
  • Loading branch information
marivaldojr authored Jun 14, 2021
2 parents e6463e0 + 969e23b commit 93dee5d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Jobs/FeedDocumentJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
use Escavador\Vespa\Common\LogManager;
use Escavador\Vespa\Common\Utils;
use Escavador\Vespa\Common\VespaExceptionSubject;
use Escavador\Vespa\Enum\LogManagerOptionsEnum;
use Escavador\Vespa\Exception\VespaFeedException;
use Escavador\Vespa\Models\DocumentDefinition;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Queue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
Expand Down Expand Up @@ -59,7 +61,7 @@ public function handle()

try {
if (count($documents) == 0) {
$this->logger->log("[$this->model]: No documents to be indexed were returned", "info");
$this->logger->log("[$this->model]: No documents to be indexed were returned", LogManagerOptionsEnum::INFO);
throw new VespaFeedException($this->model, null, "It was not possible to index any document to the Vespa.");
}

Expand Down Expand Up @@ -96,12 +98,22 @@ public function handle()
$this->model_class::markAsVespaNotIndexed($chunk);
}
}
$e = new VespaFeedException($this->model, $ex);
VespaExceptionSubject::notifyObservers($e);
throw $e;

throw $ex;
}
$total_duration = Carbon::now()->diffInSeconds($start_time);
$this->logger->log("[$this->model]: Vespa was fed in " . gmdate('H:i:s:m', $total_duration), "info");
$this->logger->log("[$this->model]: $count_indexed of " . count($documents) . " were indexed in Vespa.", "debug");
$this->logger->log("[$this->model]: Vespa was fed in " . gmdate('H:i:s:m', $total_duration), LogManagerOptionsEnum::INFO);
$this->logger->log("[$this->model]: $count_indexed of " . count($documents) . " were indexed in Vespa.", LogManagerOptionsEnum::DEBUG);
}

/**
* The job failed to process.
*
* @param \Exception $exception
* @return void
*/
public function failed(\Exception $exception = null)
{
VespaExceptionSubject::notifyObservers(new VespaFeedException($this->model, $exception));
}
}

0 comments on commit 93dee5d

Please sign in to comment.