From 62fe391cd83d9e37aac3fb590d031bec3dfeceea Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Tue, 22 Aug 2017 14:57:53 +0200 Subject: [PATCH] added retry chapter (#7) --- index.rst | 1 + retry.rst | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 retry.rst diff --git a/index.rst b/index.rst index e3a989c..7dda68a 100644 --- a/index.rst +++ b/index.rst @@ -31,6 +31,7 @@ Contents components locking + retry quick-example symfony diff --git a/retry.rst b/retry.rst new file mode 100644 index 0000000..86fa94b --- /dev/null +++ b/retry.rst @@ -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 + + 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; + } + } + +