diff --git a/src/State.php b/src/State.php index 9f82696..a8f1933 100644 --- a/src/State.php +++ b/src/State.php @@ -14,8 +14,8 @@ final class State implements StateInterface public function __construct( private readonly StateManager $manager, + private readonly string $jobCode, private readonly string $stepCode, - private readonly string $stepLabel, ) { } @@ -55,8 +55,8 @@ public function teardown(): void public function toArray(): array { return [ - 'code' => $this->stepCode, - 'label' => $this->stepLabel ?: $this->stepCode, + 'jobCode' => $this->jobCode, + 'stepCode' => $this->stepCode, 'metrics' => iterator_to_array($this->walkMetrics()), ]; } diff --git a/src/StateManager.php b/src/StateManager.php index 3ae37b9..81938e8 100644 --- a/src/StateManager.php +++ b/src/StateManager.php @@ -82,10 +82,12 @@ public static function withAuthentication( public function stepState( + string $jobCode, string $stepCode, - string $stepLabel, ): State { - return $this->steps[] = new State($this, $stepCode, $stepLabel); + $this->steps[] = $state = new State($this, $jobCode, $stepCode); + + return $state; } public function trySend($count): void @@ -118,11 +120,12 @@ private function sendUpdate(): void $this->channel->publish( json_encode([ 'messageNumber' => ++$this->messageCount, - 'id' => Uuid::uuid4(), + 'execution' => getenv('EXECUTION_ID'), 'date' => ['date' => $date->format('c'), 'tz' => $date->getTimezone()->getName()], 'stepsUpdates' => array_map(fn (State $step) => $step->toArray(), $this->steps), ], \JSON_THROW_ON_ERROR), [ + 'type' => 'update', 'content-type' => 'application/json', ], $this->exchange,