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