Skip to content

Redesign watch stream API#108

Merged
belltoy merged 4 commits into
masterfrom
feature/watch-stream
Jan 7, 2026
Merged

Redesign watch stream API#108
belltoy merged 4 commits into
masterfrom
feature/watch-stream

Conversation

@belltoy

@belltoy belltoy commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Based on #104

The WatchClient is not a high level watcher, it is just a watch API stub. So it should be only responsible for sending requests and receiving responses. Let the high level watcher decide what to do if received an unexpected response.

- WatchClient::watch(key: impl Into<Vec<u8>>, options: Option<WatchOptions>) -> Result<(WatchResponse, Watcher, WatchStream)>
+ WatchClient::watch(key: impl Into<Vec<u8>>, options: Option<WatchOptions>) -> Result<WatchStream>

The new WatchStream is different from the old version. It represents underlying bidirectional watch stream (HTTP2 stream). So it can be used to send requests and receive responses and events.

It's the user's responsibility to check the received response is a response or an event, if it is created successfully or not, or if it is a cancel response.

@belltoy belltoy added the v0.16 label Jul 9, 2025
@belltoy belltoy added v0.17 enhancement New feature or request and removed v0.16 labels Jul 10, 2025
@belltoy belltoy force-pushed the feature/watch-stream branch from 622c83f to cc1284d Compare July 13, 2025 01:38
@belltoy belltoy added this to the v0.17 milestone Jul 15, 2025
@belltoy belltoy removed the v0.17 label Jul 15, 2025
@belltoy belltoy force-pushed the feature/watch-stream branch from cc1284d to ce00c04 Compare July 15, 2025 07:43
@belltoy belltoy force-pushed the feature/watch-stream branch from ce00c04 to cbb015a Compare September 20, 2025 03:42
@belltoy belltoy modified the milestones: v0.17, v0.18 Sep 20, 2025
@belltoy belltoy force-pushed the feature/watch-stream branch 2 times, most recently from f381b32 to ef34a5f Compare January 7, 2026 03:21
@belltoy belltoy changed the base branch from master to feature/auth-interceptor January 7, 2026 03:23
@belltoy belltoy mentioned this pull request Jan 7, 2026
@belltoy belltoy force-pushed the feature/auth-interceptor branch from c491fcd to a3fbd0c Compare January 7, 2026 04:26
@belltoy belltoy force-pushed the feature/watch-stream branch 2 times, most recently from 501c58f to b810cbc Compare January 7, 2026 04:28
The `watch` function returns a tuple `(WatchResponse, Watcher, WatchStream)`, the first element
in the returned tuple is the response to the first create watch request.

More importantly, the etcd `Watch` API behaves differently than other unary RPC. It doesn't
send grpc-status in the trailers if something goes wrong. Instead, we must solve the result
via the `WatchResponse` and its corresponding request.
@belltoy belltoy force-pushed the feature/watch-stream branch from b810cbc to 5d2ce5d Compare January 7, 2026 06:44
@belltoy belltoy deleted the branch master January 7, 2026 06:45
@belltoy belltoy closed this Jan 7, 2026
@belltoy belltoy self-assigned this Jan 7, 2026
@belltoy belltoy reopened this Jan 7, 2026
@belltoy belltoy changed the base branch from feature/auth-interceptor to master January 7, 2026 06:51
@belltoy belltoy force-pushed the feature/watch-stream branch from 5d2ce5d to 13b2047 Compare January 7, 2026 07:06
@belltoy belltoy merged commit 3db1f44 into master Jan 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant