Conversation
Reviewer's GuideThis PR integrates the async-stream crate to generate streaming responses, adds a runnable example and corresponding tests, updates documentation to reference the new example, and includes the new dependency in the project manifest. Sequence diagram for streaming frames with async-stream in the examplesequenceDiagram
actor User
participant Main as main()
participant StreamResp as stream_response()
participant Stream as Stream<Frame>
User->>Main: Run example
Main->>StreamResp: Call stream_response()
StreamResp-->>Main: Return Response::Stream
Main->>Stream: Iterate stream.next() (5 times)
Stream-->>Main: Yield Frame(n)
Main->>User: Print received frame: Frame(n)
Class diagram for the new Frame struct and stream_response functionclassDiagram
class Frame {
+u32 0
+Debug
+PartialEq
+bincode::Encode
+bincode::BorrowDecode
}
class Response {
<<generic>>
+Stream(Pin<Box<dyn Stream<Item=Result<T, E>>>>)
}
Frame <.. Response : used as generic
class stream_response {
+stream_response() Response<Frame, ()>
}
stream_response ..> Response : returns
stream_response ..> Frame : yields
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes introduce the Changes
Sequence Diagram(s)sequenceDiagram
participant Main as main()
participant StreamFn as stream_response()
participant Stream as async_stream
participant Consumer as for frame in stream
Main->>StreamFn: Call stream_response()
StreamFn->>Stream: Create async stream yielding Frame(0..4)
StreamFn-->>Main: Return Response::Stream(stream)
Main->>Consumer: Extract stream from Response::Stream
loop For each frame in stream
Consumer->>Stream: Await next frame
Stream-->>Consumer: Yield Frame(n)
Consumer->>Main: Print frame
end
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
📄 Source: CodeRabbit Inference Engine (AGENTS.md) List of files the instruction was applied to:
`**/*.md`: * Avoid 2nd person or 1st person pronouns ("I", "you", "we") * Use en...
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (1)
✨ Finishing Touches🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `examples/async_stream.rs:9` </location>
<code_context>
+
+use async_stream::try_stream;
+use futures::StreamExt;
+use wireframe::response::Response;
+
+#[derive(bincode::Encode, bincode::BorrowDecode, Debug, PartialEq)]
</code_context>
<issue_to_address>
Omit unused type parameter in Response; use Response<Frame> instead of Response<Frame, ()>.
The Response type is used as Response<Frame, ()>, but the second type parameter is not required or explained. Use Response<Frame> if the second parameter is unnecessary, or document its purpose if it is required.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
Cargo.toml(1 hunks)docs/asynchronous-outbound-messaging-roadmap.md(1 hunks)docs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md(2 hunks)examples/async_stream.rs(1 hunks)tests/async_stream.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
`docs/**/*.md`: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
docs/**/*.md: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI. The tool is already installed; runnixie *.md **/*.mddirectly instead of usingnpx.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`docs/**/*.md`: Provide user guides and examples demonstrating server-initiated messaging.
docs/**/*.md: Provide user guides and examples demonstrating server-initiated messaging.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`docs/**/*.md`: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
docs/**/*.md: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
📄 Source: CodeRabbit Inference Engine (docs/contents.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`docs/**/*.md`: Use British English based on the Oxford English Dictionary (en-o...
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation.
Company names are treated as collective nouns (e.g., "Lille Industries are expanding").
Write headings in sentence case in documentation.
Use Markdown headings (#,##,###, etc.) in order without skipping levels.
Follow markdownlint recommendations for Markdown files.
Provide code blocks and lists using standard Markdown syntax.
Always use fenced code blocks with a language identifier; useplaintextfor non-code text.
Use-as the first level bullet and renumber lists when items change.
Prefer inline links using[text](url)or angle brackets around the URL in Markdown.
Expand any uncommon acronym on first use, for example, Continuous Integration (CI).
Wrap paragraphs at 80 columns in documentation.
Wrap code at 120 columns in documentation.
Do not wrap tables in documentation.
Use footnotes referenced with[^label]in documentation.
Include Mermaid diagrams in documentation where it adds clarity.
When embedding figures in documentation, useand provide concise alt text describing the content.
Add a short description before each Mermaid diagram in documentation so screen readers can understand it.
📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`docs/**/*.md`: Write the official documentation for the new features. Create se...
docs/**/*.md: Write the official documentation for the new features. Create separate guides for "Duplex Messaging & Pushes", "Streaming Responses", and "Message Fragmentation". Each guide must include runnable examples and explain the relevant concepts and APIs.
📄 Source: CodeRabbit Inference Engine (docs/wireframe-1-0-detailed-development-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`**/*.md`: * Avoid 2nd person or 1st person pronouns ("I", "you", "we") * Use en...
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-oxendic spelling and grammar.
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
`Cargo.toml`: Use explicit version ranges in `Cargo.toml` and keep dependencies up-to-date.
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
Cargo.toml
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
examples/async_stream.rstests/async_stream.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments must use en-GB-oxendict spelling and grammar.
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
examples/async_stream.rstests/async_stream.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-roadmap.md:0-0
Timestamp: 2025-06-30T23:03:19.564Z
Learning: Applies to docs/**/*.rs : Document the use of `async-stream` for creating `Response::Stream` values.
docs/asynchronous-outbound-messaging-roadmap.md (1)
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-roadmap.md:0-0
Timestamp: 2025-06-30T23:03:19.564Z
Learning: Applies to docs/examples/**/*.rs : Include an example handler using `async-stream` demonstrating `Response::Stream` generation in the examples directory.
🧬 Code Graph Analysis (1)
tests/async_stream.rs (2)
tests/connection_actor.rs (1)
queues(18-18)src/push.rs (1)
bounded(135-149)
🪛 LanguageTool
docs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md
[grammar] ~45-~45: Please add a punctuation mark at the end of paragraph.
Context: ...perative model. Handlers will return an enhanced Response enum, giving developers cle...
(PUNCTUATION_PARAGRAPH_END)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
🔇 Additional comments (10)
Cargo.toml (1)
23-23: LGTM: Appropriate dev-dependency addition.The
async-streamcrate is correctly added as a dev-dependency with an explicit version range, which aligns with the coding guidelines for dependency management.docs/asynchronous-outbound-messaging-roadmap.md (1)
34-35: LGTM: Roadmap task correctly marked as complete.The checklist item accurately reflects the completion of the example handler and provides a clear reference to the specific file location.
docs/the-road-to-wireframe-1-0-feature-set-philosophy-and-capability-maturity.md (1)
91-91: LGTM: Helpful reference to practical example.The addition of the example reference provides readers with a concrete demonstration of the streaming pattern described in the documentation.
tests/async_stream.rs (3)
1-5: LGTM: Well-documented module purpose.The module-level documentation clearly explains the purpose and utility of the test module, following the coding guidelines requirement.
15-21: LGTM: Clean stream generation function.The function demonstrates proper use of
async_stream::try_stream!with appropriate error handling and simple, focused test data.
23-34: LGTM: Comprehensive integration test.The test properly verifies the integration between async-stream and ConnectionActor, ensuring frames are processed in the correct order. Good use of rstest and appropriate setup of test infrastructure.
examples/async_stream.rs (4)
1-6: LGTM: Clear example documentation.The module-level documentation effectively explains the example's purpose and demonstrates the key concepts being illustrated.
11-12: LGTM: Appropriate derive macros.The Frame struct uses the correct derive macros for serialisation and debugging, which are essential for the wireframe framework.
14-21: LGTM: Clean stream generation pattern.The function demonstrates the canonical pattern for creating
Response::Streamvalues usingasync_stream::try_stream!, which aligns with the framework's recommended approach.
23-31: LGTM: Practical consumption example.The main function shows realistic usage of the generated stream with proper pattern matching and error handling, making it a valuable reference for users.
Summary
async-streamdev dependencyResponse::Streamwithasync_streaminexamples/async_stream.rsasync-streamTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_686667d027448322b7c3ecb4677ba41d
Summary by Sourcery
Add an async-stream based example and tests for streaming responses, update docs and roadmap entries, and include the async-stream dependency.
Enhancements:
Build:
Documentation:
Tests: