-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f723168
commit 62fe391
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ Contents | |
|
||
components | ||
locking | ||
retry | ||
quick-example | ||
symfony | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Retry | ||
===== | ||
Some of the tasks which will be executed by a handler are risky and could fail | ||
(e.g. long running, i/o ...). To allow retry of this tasks the handler is able | ||
to implement the interface ``RetryTaskHandlerInterface`` and specify a maximum | ||
amount of attempts to pass the task. | ||
|
||
The retries will be scheduled as soon as possible and the following tasks will | ||
be scheduled after this retry later. This prevent the following tasks to fail | ||
because of bad starting conditions because of the previous task. | ||
|
||
Example | ||
******* | ||
|
||
.. code-block:: php | ||
<?php | ||
include __DIR__ . '/vendor/autoload.php'; | ||
class ImageResizeHandler implements Task\Handler\TaskHandlerInterface, Task\Executor\RetryTaskHandlerInterface | ||
{ | ||
public function handle($workload) | ||
{ | ||
try { | ||
$this->doSomething(); | ||
} catch (SpecificException $exception) { | ||
throw new FailedException($exception); | ||
} | ||
// other exceptions will be propagated to the runner | ||
// the runner will retry the execution until the max-attempts are reached | ||
} | ||
public function getMaximumAttempts() | ||
{ | ||
return 3; | ||
} | ||
} | ||