feat(stream): add streaming support for watch channels#4
Merged
George-Miao merged 5 commits intocompio-rs:masterfrom Nov 12, 2025
Merged
feat(stream): add streaming support for watch channels#4George-Miao merged 5 commits intocompio-rs:masterfrom
George-Miao merged 5 commits intocompio-rs:masterfrom
Conversation
- Introduce `future_store` module with boxed future storage utilities - Add `stream` module with `SyncWatchStream` and `UnsyncWatchStream` implementations - Implement `into_stream()` methods for receivers when "stream" feature is enabled - Add comprehensive tests for stream functionality in both sync and unsync versions - Update dependencies to include `futures-util` and `scopeguard` - Gate stream functionality behind optional "stream" feature flag
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds streaming capabilities to the watch channel implementation, providing Stream trait implementations for both synchronized and unsynchronized watch channels. This enables users to consume watch channel updates using the familiar async stream API from the futures ecosystem.
Key Changes:
- Introduces
SyncWatchStreamandUnsyncWatchStreamtypes that implement theStreamtrait - Adds a memory-efficient
future_storemodule for reusing boxed future allocations - Extends
Receiverwithinto_stream()convenience methods
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stream.rs | New module providing Stream implementations for both sync and unsync watch channels with comprehensive documentation |
| src/future_store.rs | New internal module implementing efficient boxed future storage with memory reuse optimization |
| src/sync.rs | Adds into_stream() method to sync Receiver for convenient stream conversion |
| src/unsync.rs | Adds into_stream() method to unsync Receiver for convenient stream conversion |
| src/lib.rs | Registers new stream and future_store modules under feature flag |
| Cargo.toml | Adds futures-util and scopeguard dependencies, defines stream feature flag |
| Cargo.lock | Updates lock file with new dependencies |
| tests/smol.rs | Adds tests for stream functionality with smol runtime |
| tests/compio_sync.rs | Adds tests for sync stream functionality with compio runtime |
| tests/compio_unsync.rs | Adds tests for unsync stream functionality with compio runtime |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Implement `into_stream` for both sync and unsync `Receiver` types - Enable immediate yielding of current value followed by updates - Stream ends when the channel is closed - Update Cargo.toml to enable "stream" feature by default - Remove unnecessary `unsafe impl Sync` for `LocalBoxedFutureStore`
Member
|
Let's rename the stream to just [Un]syncStream or [Un]syncSeeStream and we should be good to merge. |
…chStream` to `UnsyncStream`
Collaborator
Author
|
Maybe it can be merged now? @George-Miao |
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.
future_storemodule with boxed future storage utilitiesstreammodule withSyncWatchStreamandUnsyncWatchStreamimplementationsinto_stream()methods for receivers when "stream" feature is enabledfutures-utilandscopeguard