1 | <?php |
||
18 | abstract class HttpClientPool implements HttpClientPoolInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var HttpClientPoolItem[] |
||
22 | */ |
||
23 | protected $clientPool = []; |
||
24 | |||
25 | /** |
||
26 | * Add a client to the pool. |
||
27 | * |
||
28 | * @param ClientInterface|HttpAsyncClient|HttpClientPoolItem $client |
||
29 | */ |
||
30 | 14 | public function addHttpClient($client) |
|
38 | |||
39 | /** |
||
40 | * Return an http client given a specific strategy. |
||
41 | * |
||
42 | * @throws HttpClientNotFoundException When no http client has been found into the pool |
||
43 | * |
||
44 | * @return HttpClientPoolItem Return a http client that can do both sync or async |
||
45 | */ |
||
46 | abstract protected function chooseHttpClient(): HttpClientPoolItem; |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 6 | public function sendAsyncRequest(RequestInterface $request) |
|
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | 14 | public function sendRequest(RequestInterface $request): ResponseInterface |
|
63 | } |
||
64 |