RandomClientPool
extends HttpClientPool
in package
FinalYes
RoundRobinClientPool will choose the next client in the pool.
Tags
Table of Contents
Properties
- $clientPool : array<string|int, HttpClientPoolItem>
Methods
- addHttpClient() : void
- Add a client to the pool.
- sendAsyncRequest() : Promise
- Sends a PSR-7 request in an asynchronous way.
- sendRequest() : ResponseInterface
- Sends a PSR-7 request and returns a PSR-7 response.
- chooseHttpClient() : HttpClientPoolItem
- Return an http client given a specific strategy.
Properties
$clientPool
protected
array<string|int, HttpClientPoolItem>
$clientPool
= []
Methods
addHttpClient()
Add a client to the pool.
public
addHttpClient(ClientInterface|HttpAsyncClient $client) : void
Parameters
- $client : ClientInterface|HttpAsyncClient
sendAsyncRequest()
Sends a PSR-7 request in an asynchronous way.
public
sendAsyncRequest(RequestInterface $request) : Promise
Parameters
- $request : RequestInterface
Return values
Promise —resolves a PSR-7 Response or fails with an Http\Client\Exception
sendRequest()
Sends a PSR-7 request and returns a PSR-7 response.
public
sendRequest(RequestInterface $request) : ResponseInterface
Parameters
- $request : RequestInterface
Return values
ResponseInterfacechooseHttpClient()
Return an http client given a specific strategy.
protected
chooseHttpClient() : HttpClientPoolItem
Return values
HttpClientPoolItem —Return a http client that can do both sync or async