Open Monograph Press
3.3.0
AbstractBackoffStrategy.php
1
<?php
2
3
namespace
Guzzle\Plugin\Backoff
;
4
5
use
Guzzle\Http\Message\RequestInterface
;
6
use
Guzzle\Http\Message\Response
;
7
use
Guzzle\Http\Exception\HttpException
;
8
12
abstract
class
AbstractBackoffStrategy
implements
BackoffStrategyInterface
13
{
15
protected
$next
;
16
18
public
function
setNext
(
AbstractBackoffStrategy
$next
)
19
{
20
$this->next =
$next
;
21
}
22
28
public
function
getNext
()
29
{
30
return
$this->next
;
31
}
32
33
public
function
getBackoffPeriod
(
34
$retries,
35
RequestInterface
$request,
36
Response
$response =
null
,
37
HttpException
$e =
null
38
) {
39
$delay = $this->
getDelay
($retries, $request, $response, $e);
40
if
($delay ===
false
) {
41
// The strategy knows that this must not be retried
42
return
false
;
43
} elseif ($delay ===
null
) {
44
// If the strategy is deferring a decision and the next strategy will not make a decision then return false
45
return
!$this->next || !$this->next->makesDecision()
46
? false
47
: $this->next->getBackoffPeriod($retries, $request, $response, $e);
48
} elseif ($delay ===
true
) {
49
// if the strategy knows that it must retry but is deferring to the next to determine the delay
50
if
(!$this->next) {
51
return
0;
52
}
else
{
53
$next
=
$this->next
;
54
while
(
$next
->makesDecision() &&
$next
->getNext()) {
55
$next
=
$next
->getNext();
56
}
57
return
!
$next
->makesDecision() ?
$next
->getBackoffPeriod($retries, $request, $response, $e) : 0;
58
}
59
}
else
{
60
return
$delay;
61
}
62
}
63
72
abstract
public
function
makesDecision
();
73
85
abstract
protected
function
getDelay
(
86
$retries,
87
RequestInterface
$request,
88
Response
$response =
null
,
89
HttpException
$e =
null
90
);
91
}
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\getNext
getNext()
Definition:
AbstractBackoffStrategy.php:31
Guzzle\Http\Message\RequestInterface
Definition:
lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/RequestInterface.php:16
Guzzle\Plugin\Backoff\AbstractBackoffStrategy
Definition:
AbstractBackoffStrategy.php:12
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\getBackoffPeriod
getBackoffPeriod( $retries, RequestInterface $request, Response $response=null, HttpException $e=null)
Definition:
AbstractBackoffStrategy.php:36
Guzzle\Http\Exception\HttpException
Definition:
lib/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/HttpException.php:10
Guzzle\Http\Message\Response
Definition:
paymethod/paypal/lib/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Response.php:17
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\getDelay
getDelay( $retries, RequestInterface $request, Response $response=null, HttpException $e=null)
Guzzle\Plugin\Backoff
Definition:
AbstractBackoffStrategy.php:3
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\$next
$next
Definition:
AbstractBackoffStrategy.php:18
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\setNext
setNext(AbstractBackoffStrategy $next)
Definition:
AbstractBackoffStrategy.php:21
Guzzle\Plugin\Backoff\AbstractBackoffStrategy\makesDecision
makesDecision()
Guzzle\Plugin\Backoff\BackoffStrategyInterface
Definition:
BackoffStrategyInterface.php:12
plugins
paymethod
paypal
lib
vendor
guzzle
guzzle
src
Guzzle
Plugin
Backoff
AbstractBackoffStrategy.php
Generated on Fri Aug 28 2020 14:51:15 for Open Monograph Press by
1.8.17