| 1 | <?php |
||
| 14 | abstract class HttpClientPool implements HttpAsyncClient, HttpClient |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var HttpClientPoolItem[] |
||
| 18 | */ |
||
| 19 | protected $clientPool = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Add a client to the pool. |
||
| 23 | * |
||
| 24 | * @param HttpClient|HttpAsyncClient|HttpClientPoolItem $client |
||
| 25 | */ |
||
| 26 | 14 | public function addHttpClient($client) |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Return an http client given a specific strategy. |
||
| 37 | * |
||
| 38 | * @throws HttpClientNotFoundException When no http client has been found into the pool |
||
| 39 | * |
||
| 40 | * @return HttpClientPoolItem Return a http client that can do both sync or async |
||
| 41 | */ |
||
| 42 | abstract protected function chooseHttpClient(); |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | 6 | public function sendAsyncRequest(RequestInterface $request) |
|
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | 13 | public function sendRequest(RequestInterface $request) |
|
| 59 | } |
||
| 60 |