Skip to content

Commit

Permalink
added retry chapter (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored and chirimoya committed Aug 22, 2017
1 parent f723168 commit 62fe391
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Contents

components
locking
retry
quick-example
symfony

Expand Down
41 changes: 41 additions & 0 deletions retry.rst
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;
}
}

0 comments on commit 62fe391

Please sign in to comment.