refactor(async): use Amp futures and HTTP transport#330
Open
simPod wants to merge 9 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #330 +/- ##
==========================================
- Coverage 94.33% 94.32% -0.01%
==========================================
Files 42 42
Lines 742 776 +34
==========================================
+ Hits 700 732 +32
- Misses 42 44 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9233939 to
5bbee57
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the async ClickHouse client to be Amp-first by returning Amp\Future from the async API and switching the async HTTP transport from HTTPlug promises to amphp/http-client, while keeping the sync client PSR-18 based.
Changes:
- Change
ClickHouseAsyncClient::select()/selectWithParams()to returnAmp\Futureand update async implementation accordingly. - Replace the async transport with
amphp/http-clientand update async tests to await futures. - Refactor
ServerErrorcreation to support non-PSR response content/status inputs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/WithClient.php | Switch async test client wiring to Amp HTTP client and pass base URI + headers explicitly. |
| tests/Client/SelectAsyncTest.php | Update async tests from Guzzle promises to Amp\Future\await() / Future::await(). |
| src/Exception/ServerError.php | Add fromResponseContent() to build errors from raw body/status (used by Amp transport). |
| src/Client/PsrClickHouseAsyncClient.php | Implement Amp-based request execution returning Future and convert PSR requests to Amp requests. |
| src/Client/ClickHouseAsyncClient.php | Update async client interface return types to Amp\Future with generic return phpdoc. |
| composer.json | Replace HTTPlug/Guzzle promises deps with amphp/amp and amphp/http-client. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+111
to
+115
| try { | ||
| $response = $this->client->request($this->toAmpRequest($request)); | ||
| $body = $response->getBody()->buffer(); | ||
|
|
||
| $this->sqlLogger?->stopQuery($id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Consumers experimenting with PHP Fiber fan-out need an Amp-first async API and transport instead of adapting HTTPlug promises at every call site. Existing promise consumers are not a constraint for this sketch.
Decision
Change
ClickHouseAsyncClient::select()andselectWithParams()to returnAmp\Futuredirectly. Replace the async implementation's HTTPlugHttpAsyncClienttransport withamphp/http-client, useamphp/http-client-psr7for PSR-7 request adaptation, remove the directguzzlehttp/promisesandphp-http/client-commondependencies, and update async tests to use Amp HTTP andAmp\Future\await(). Add asyncselectStream()andselectStreamWithParams()methods returningFuture<Payload>to mirror the sync streaming API.Consequences
guzzlehttp/psr7remains becauseRequestFactorystill usesMultipartStream.