ClickHouse / ClickHouse/clickhouse-cs
ClickHouseRawResult.ReadAsStringAsync (and friends) should support cancellation
- Dominant language
- C#
- Stars
- 94
- Forks
- 22
- Avg merge
- 11h 26m
- Merged PRs (30d)
- 22
Description
### Use case
I want to be able to cancel calls like `rawResult.ReadAsStringAsync()`.
### Describe the solution you'd like
The usual: take an optional `CancellationToken` as a parameter:
```cs
var x = await rawResult.ReadAsStringAsync(cancellationToken)
```
This is not the case currently:
https://github.com/ClickHouse/clickhouse-cs/blob/dd51bfe82a03f0cd47bba74079d288ac8423d347/ClickHouse.Driver/ADO/Readers/ClickHouseRawResult.cs#L120-L124
Note: the cancellationToken passed to `ExecuteRawResultAsync` does not carry over to reads from the returned `ClickHouseRawResult`. Maybe the docs should warn about it.
### Workaround
Not ideal, but sometimes is acceptable.
```cs
var stream = await rawResult.ReadAsStreamAsync();
using (reader = new StreamReader(stream)) {
return await reader.ReadToEndAsync(cancellationToken)
}
```
Contributor guide
Research direction
Start with ClickHouse.Driver/ADO/Readers/ClickHouseRawResult.cs at the referenced lines around ReadAsStringAsync, then inspect the related async read methods and ExecuteRawResultAsync. Confirm how cancellation is currently handled between execution and reads. Done means the relevant read methods accept an optional CancellationToken and the documentation addresses whether execution cancellation carries over.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100