Skip to content

Comments

feat(stream): add streaming support for watch channels#4

Merged
George-Miao merged 5 commits intocompio-rs:masterfrom
OpenTritium:into_stream
Nov 12, 2025
Merged

feat(stream): add streaming support for watch channels#4
George-Miao merged 5 commits intocompio-rs:masterfrom
OpenTritium:into_stream

Conversation

@OpenTritium
Copy link
Collaborator

  • 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

- 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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SyncWatchStream and UnsyncWatchStream types that implement the Stream trait
  • Adds a memory-efficient future_store module for reusing boxed future allocations
  • Extends Receiver with into_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`
@George-Miao
Copy link
Member

Let's rename the stream to just [Un]syncStream or [Un]syncSeeStream and we should be good to merge.

@OpenTritium
Copy link
Collaborator Author

Maybe it can be merged now? @George-Miao

Copy link
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@George-Miao George-Miao merged commit f41697a into compio-rs:master Nov 12, 2025
3 checks passed
@OpenTritium OpenTritium deleted the into_stream branch November 12, 2025 06:46
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.

3 participants