1 | <?php |
||
18 | class HttpClientPoolItem implements HttpClient, HttpAsyncClient |
||
19 | { |
||
20 | /** @var int Number of request this client is currently sending */ |
||
21 | private $sendingRequestCount = 0; |
||
22 | |||
23 | /** @var bool Status of the http client */ |
||
24 | private $disabled = false; |
||
25 | |||
26 | /** @var \DateTime Time when this client has been disabled */ |
||
27 | private $disabledAt; |
||
28 | |||
29 | /** @var int|null Number of seconds after this client is reenable, by default null: never reenable this client */ |
||
30 | private $reenableAfter; |
||
31 | |||
32 | /** @var FlexibleHttpClient A http client responding to async and sync request */ |
||
33 | private $client; |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | * |
||
38 | * @param null|int $reenableAfter Number of seconds after this client is reenable |
||
39 | */ |
||
40 | 8 | public function __construct($client, $reenableAfter = null) |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 6 | public function sendRequest(RequestInterface $request) |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 2 | public function sendAsyncRequest(RequestInterface $request) |
|
91 | |||
92 | /** |
||
93 | * Get current number of request that is send by the underlying http client. |
||
94 | * |
||
95 | * @return int |
||
96 | */ |
||
97 | public function getSendingRequestCount() |
||
101 | |||
102 | /** |
||
103 | * Disable the current client. |
||
104 | */ |
||
105 | 4 | protected function disable() |
|
110 | |||
111 | /** |
||
112 | * Whether this client is disabled or not. |
||
113 | * |
||
114 | * Will also reactivate this client if possible |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 8 | public function isDisabled() |
|
131 | } |
||
132 |