Skip to content

feat: support cancellation in async queries - #350

Open
simPod wants to merge 2 commits into
masterfrom
feat/async-cancellation
Open

simPod wants to merge 2 commits into
masterfrom
feat/async-cancellation

Conversation

@simPod

@simPod simPod commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Async operations need a per-operation way to stop HTTP work without rebuilding the client or duplicating its transport logic.

All four async select methods now accept an optional Amp cancellation token. It applies to the request, buffered response bodies, and later reads of a returned payload, including reads made without another token. Explicit read tokens are combined with the operation token. Closing, EOF, cancellation, and terminal failures release the owned resources and subscriptions.

The implementation requires amphp/pipeline 1.2.1 or later, which fixes a double-resolution defect when cancellation and stream closure affect the same pending read.

Existing calls remain compatible. Implementations of ClickHouseAsyncClient and subclasses overriding these methods must add the optional argument and forward it when delegating. Cancellation stops client I/O; it does not guarantee that ClickHouse has stopped executing the query.

Accept an optional per-operation Amp cancellation token and retain it through HTTP requests, buffered bodies and streamed payload reads. Release body resources and cancellation subscriptions when consumption ends. Existing callers remain compatible; interface implementations and overriding subclasses must add the optional argument.
Require amphp/pipeline ^1.2.1 to exclude the confirmed pending-read double-resolution defect. Preserve the per-operation cancellation behavior and improve retained-response, stream-notification and abandoned-stream cleanup proof. Correct static-analysis and style contracts without changing the declared generic format types; isolate the reproduced Parts snippet false positive to one exact diagnostic.
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.80851% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.76%. Comparing base (a48ea49) to head (e13d961).

Files with missing lines Patch % Lines
src/Client/PsrClickHouseAsyncClient.php 92.85% 2 Missing ⚠️
src/Client/Http/CancellationStream.php 98.48% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #350      +/-   ##
==========================================
+ Coverage   96.43%   96.76%   +0.33%     
==========================================
  Files          43       44       +1     
  Lines         953     1082     +129     
==========================================
+ Hits          919     1047     +128     
- Misses         34       35       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant