Lines n/a 0 / 0
Functions and Methods n/a 0 / 0
Classes and Traits n/a 0 / 0
Name Lines Functions and Methods CRAP Classes and Traits
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\Hermes\Handler;
6
7use Throwable;
8use Tomaj\Hermes\MessageInterface;
9
10/**
11 * A handler whose failed messages the dispatcher may send again.
12 *
13 * When handle() throws, Dispatcher calls canRetry() with the message and the exception. A retry
14 * copy is sent only when it returns true and the message has fewer than maxRetry() retries.
15 * RetryTrait implements both methods (always retry, at most 25 times).
16 */
17interface RetryableHandlerInterface extends HandlerInterface
18{
19    /**
20     * Return false to skip the retry, for example for a permanent error such as invalid input.
21     */
22    public function canRetry(MessageInterface $message, Throwable $exception): bool;
23
24    /**
25     * How many retries a message gets at most. 0 turns retries off.
26     */
27    public function maxRetry(): int;
28}