Skip to content

Commit

Permalink
wip: modified ClientFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
il-masaru-yamagishi committed Sep 5, 2023
1 parent bc88540 commit 7904406
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 94 deletions.
2 changes: 1 addition & 1 deletion src/HttpClient/AmphpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
final class AmphpClient implements HttpClientInterface
{
/** @var Closure[] $middlewares */
/** @var list<Closure(RequestInterface $request, callable $next): ResponseInterface> $middlewares */
private array $middlewares = [];

public function __construct(
Expand Down
4 changes: 0 additions & 4 deletions src/HttpClient/BuzzClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Buzz\Client\BuzzClientInterface;
use Closure;
use Heavyrain\Contracts\ClientInterface;
use Heavyrain\Executor\Middlewares\IdentifyRequestMiddleware;
use Heavyrain\Executor\Middlewares\ProfilingMiddleware;
use Heavyrain\Executor\Middlewares\WaitSendRequestMiddleware;
use Heavyrain\Scenario\Client;
Expand Down Expand Up @@ -43,9 +42,6 @@ public function createClient(?BuzzClientInterface $buzzClient = null): ClientInt
'verify' => $this->config->sslVerify,
'timeout' => $this->config->timeout,
]);
// TODO: implement uniqid every client
$clientId = \uniqid();
$client->addMiddleware(new IdentifyRequestMiddleware($clientId));
$client->addMiddleware(new ProfilingMiddleware($this->profiler));
$client->addMiddleware(new WaitSendRequestMiddleware($this->config->waitAfterSendRequestSec));

Expand Down
8 changes: 7 additions & 1 deletion src/HttpClient/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
use Laminas\Diactoros\UriFactory;

/**
* Client factory
* A factory for creating HTTP clients.
*/
final class ClientFactory
{
/**
* Creates a new HTTP client instance with the specified base URI.
*
* @param string $baseUri The base URI for the HTTP client.
* @return ClientInterface The newly created HTTP client instance.
*/
public static function create(string $baseUri): ClientInterface
{
$ampHttpClient = (new HttpClientBuilder())
Expand Down
88 changes: 0 additions & 88 deletions src/Support/DefaultHttpBuilder.php

This file was deleted.

0 comments on commit 7904406

Please sign in to comment.