Skip to content

Commit 0a0d4b1

Browse files
authored
refactor(async-queue): strengthen Result type handling in Driver and AfterHandle event (#7603)
1 parent 3a5bb94 commit 0a0d4b1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Driver/Driver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ protected function getCallback($data, $message): callable
120120
$this->event?->dispatch(new BeforeHandle($message));
121121

122122
$result = $message->job()->handle();
123+
$result = $result instanceof Result ? $result : Result::ACK;
123124

124125
match ($result) {
125126
Result::REQUEUE => $this->remove($data) && $this->retry($data),
126127
Result::RETRY => $this->remove($data) && $message->attempts() && $this->retry($message),
127128
Result::DROP => $this->remove($data),
128129
Result::ACK => $this->ack($data),
129-
default => $this->ack($data),
130130
};
131131

132-
$this->event?->dispatch(new AfterHandle($message, $result instanceof Result ? $result : null));
132+
$this->event?->dispatch(new AfterHandle($message, $result));
133133
} catch (Throwable $ex) {
134134
if (isset($message, $data)) {
135135
if ($message->attempts() && $this->remove($data)) {

src/Event/AfterHandle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class AfterHandle extends Event
1919
{
20-
public function __construct(MessageInterface $message, public ?Result $result = null)
20+
public function __construct(MessageInterface $message, public Result $result)
2121
{
2222
parent::__construct($message);
2323
}

0 commit comments

Comments
 (0)