Skip to content

Commit

Permalink
Merge pull request #10 from vivait/fix/adhoc-2812-store-job-id
Browse files Browse the repository at this point in the history
Store job ID in static property when job performed
  • Loading branch information
kieljohn authored Jun 30, 2023
2 parents 1dfcd40 + c0bf0f1 commit 6396d18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Vivait/DelayedEventBundle/Command/ProcessJobCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Throwable;
use Vivait\DelayedEventBundle\Exception\TerminalEventException;
use Vivait\DelayedEventBundle\Exception\TransientEventException;
use Vivait\DelayedEventBundle\Job;
use Vivait\DelayedEventBundle\Serializer\SerializerInterface;

class ProcessJobCommand extends Command
Expand Down Expand Up @@ -106,6 +107,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
private function performJob($jobId, $eventName, $event)
{
Job::$id = $jobId;

try {
$this->eventDispatcher->dispatch($event, $eventName);
} catch (TerminalEventException $exception) {
Expand Down
16 changes: 16 additions & 0 deletions src/Vivait/DelayedEventBundle/Job.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace Vivait\DelayedEventBundle;

/**
* Allow job ID or other metadata to be used in process.
*/
final class Job
{
/**
* The ID of the job currently being processed (null indicates no job).
*/
public static ?string $id = null;
}

0 comments on commit 6396d18

Please sign in to comment.