Skip to content

Add echo example and route test utilities#86

Merged
leynos merged 2 commits intomainfrom
codex/create-echo-server-example-with-tests
Jun 20, 2025
Merged

Add echo example and route test utilities#86
leynos merged 2 commits intomainfrom
codex/create-echo-server-example-with-tests

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 20, 2025

Summary

  • add examples/echo.rs showing basic server setup
  • introduce test utility to run an app with frames
  • test routing logic with serialized request/response

Testing

  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_68555d3a96408322bdbe678fd8da1844

Summary by Sourcery

Add an echo server example, introduce utilities to test the app with wireframe frames, and add a route test verifying request/response echo logic

New Features:

  • Add echo.rs example demonstrating basic server setup and middleware use
  • Introduce test utility functions to run the app with a single frame over an in-memory duplex connection

Tests:

  • Add a routing test that sends a serialized request frame and asserts echo response behavior

Summary by CodeRabbit

  • New Features
    • Added a new example demonstrating a basic server setup.
  • Tests
    • Introduced a test verifying that messages are echoed correctly and handlers are invoked as expected.
    • Added supporting test data structures and utility functions for simulating app interactions.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 20, 2025

Reviewer's Guide

Adds an echo server example with logging middleware and routing, introduces in-memory frame-based test utilities, and provides an async routing test using length-prefixed framing to verify echo behavior.

Sequence diagram for echo request handling in the example server

sequenceDiagram
    actor Client
    participant Server as WireframeServer
    participant App as WireframeApp
    participant Logger
    Client->>Server: Connect & send request (route 1)
    Server->>App: Pass request
    App->>Logger: (Middleware marker, no hooks)
    App->>App: Route handler invoked
    App-->>Server: Echo response
    Server-->>Client: Send echoed response
Loading

Class diagram for echo server example and middleware

classDiagram
    class Logger {
        <<Middleware>>
    }
    class WireframeApp {
        +new()
        +wrap(middleware)
        +route(route_id, handler)
    }
    class WireframeServer {
        +new(factory)
        +bind(address)
        +run()
    }
    Logger --|> Middleware
    WireframeApp o-- Logger : wraps
    WireframeServer o-- WireframeApp : uses factory
Loading

File-Level Changes

Change Details Files
Add echo server example demonstrating basic server setup with middleware and routing
  • Introduced Logger middleware via the wrap API
  • Configured a route that logs incoming requests and relies on automatic echo behavior
  • Instantiated WireframeServer binding to 127.0.0.1:7878 and running the app
examples/echo.rs
Introduce in-memory frame-based test utilities
  • Implemented run_app_with_frame and run_app_with_frame_with_capacity functions
  • Used tokio::duplex streams to simulate client-server I/O
  • Handled frame writing, shutdown, and response collection in a spawned server task
tests/util.rs
Add async routing test using serialized frames to verify echo behavior
  • Defined TestEnvelope and Echo types with bincode serialization
  • Set up a WireframeApp with LengthPrefixedProcessor and an echo route handler
  • Sent a length-prefixed request frame, invoked run_app_with_frame, deserialized the response, and asserted echo value and handler invocation
tests/routes.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 20, 2025

Walkthrough

A new example demonstrating a basic Wireframe server with middleware is added. Additionally, asynchronous test utilities and a new test are introduced to verify echo functionality and message handling. Supporting data structures and helper functions are included to facilitate in-memory testing of the server's response behaviour.

Changes

File(s) Change Summary
examples/echo.rs Added a new example showing a Wireframe server with a custom Logger middleware and a simple route handler.
tests/routes.rs Added an async test for echo message handling, with supporting structs (TestEnvelope, Echo).
tests/util.rs Added async utility functions run_app_with_frame and run_app_with_frame_with_capacity for in-memory app testing with frames.

Possibly related PRs

  • Implement basic middleware wrappers #80: Enhances middleware capabilities by modifying ServiceRequest and ServiceResponse to hold frame data and enabling middleware wrappers for frame manipulation, closely related to the middleware example added here.
  • Implement trait foundations #8: Introduces foundational asynchronous middleware traits (Service, Transform) that the new Logger middleware example builds upon.
  • Implement connection handling #76: Implements core connection handling logic in WireframeApp including frame decoding and handler dispatch, which the new example relies on.

Poem

A server now echoes with glee,
Middleware logs, as swift as can be.
Tests send a message, and back it will go,
Framed in the wires, a binary flow.
With helpers and structs, the rabbits all cheer—
More robust and clear, our code hops this year!
🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb072a5 and ea2f7c5.

📒 Files selected for processing (3)
  • examples/echo.rs (1 hunks)
  • tests/routes.rs (1 hunks)
  • tests/util.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (5)
examples/echo.rs (1)

21-29: ```shell
#!/bin/bash

Display the complete test for automatic echoing

cat tests/routes.rs


</details>
<details>
<summary>tests/util.rs (2)</summary>

`22-24`: **Clean wrapper function with appropriate delegation.**

The `run_app_with_frame` function provides a clean interface by delegating to the more configurable variant with a sensible default capacity.

---

`35-53`: **Well-implemented async test utility with proper resource management.**

The implementation correctly:
- Creates a duplex stream for in-memory testing
- Spawns the app handling in a separate task
- Properly shuts down the client connection
- Reads the complete response
- Waits for the server task to complete

The error handling and resource management are appropriate for a test utility.

</details>
<details>
<summary>tests/routes.rs (2)</summary>

`18-26`: **Well-defined test data structures with proper serialization traits.**

The `TestEnvelope` and `Echo` structs are properly defined with the necessary traits for Bincode serialization and testing (`PartialEq`, `Debug`).

---

`45-66`: **Comprehensive test implementation with proper serialization and assertions.**

The test properly:
- Serializes the test data using Bincode
- Encodes it with the frame processor
- Runs it through the app using the test utility
- Deserializes and verifies the response
- Asserts both the echoed content and handler invocation count

The implementation demonstrates good testing practices.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgBBWnpRWHxIEgAPNGZuaPQMegp8PBIIkMg8eC91eGlQ2MgAdzRkBwFmdRp6OQjYUuxESkho2Qx8ZBbrOwxHASGADgA2DRg+xlhMUmR4DAYvbCV0JJ2idEhyRvSsnLyAMyrSgANM7NzpAHoU/A0KREfe6iQJTMfAYRC4Kg0CaQAQteAMeyUKR8Qa4bDcJrqWCQDpJaLNfz5QrFcQYIgrRK0GqgtA+WThXBrWwoDAQxTYBjSM5Q3AVcTVXDyBi06L0R4UbAYAD6aG43CljSxUtuVDY/yUiHgRHI9AIfklZwA6vB/CrsiR4nLMYzERR4LT4AAvGJmtiIcJkFTVMmQW4kOgnPyBYLgiYFBQ+USk07+RDcUGDbZYNC+1UxZiYcgUFZwUpFSo+rz4IjwlDIHkxRn5ojYzDoRCjBiwIpjAZlcEA3mDO0O53IfxBEJhwrSeNgrkDQPRMmMsC8Ej3DIu1UncItbvR3qlL4wkgbCTwfB8TD0ZHwW6yQMbArRPg7CT4YXiUE5tY8wO8R/SZC3I9bwbrJsXL3vgXhSP2koYIGjwZgA1qU3q4P8J6QDBaDwe2SERGkZAOISTCHEEDqCkS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cscmgAAKzHJSYACcJA2OpyaAaAxyWJxyJAhJhJ9yxySQOJtwiwlJde2JtwqgaJI86QFJtwpyDAuJaApyZSpyUmAgfJuJZSJAiwZSFyFyUmMmcpUmiw8wtwSgaA2OokZSBcaJBg3JiUsJ8J1aw0SJlckJQAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings
<details open="true">
<summary>🧪 Generate Unit Tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-2992037301"} -->   Create PR with Unit Tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-2992037301"} -->   Post Copyable Unit Tests in Comment
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-2992037301"} -->   Commit Unit Tests in branch `codex/create-echo-server-example-with-tests`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=leynos/wireframe&utm_content=86):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) 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)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai auto-generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • The echo example’s handler is currently a no-op; update it to forward the incoming message back to the client so it actually demonstrates echo functionality.
  • The Logger middleware in examples/echo.rs has no implementation; consider adding simple println! hooks in middleware methods to illustrate logging behavior.
  • The run_app_with_frame test utility uses a fixed 1024-byte duplex buffer, which may not accommodate larger frames—consider making the buffer size configurable or increasing its default capacity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The echo example’s handler is currently a no-op; update it to forward the incoming message back to the client so it actually demonstrates echo functionality.
- The Logger middleware in examples/echo.rs has no implementation; consider adding simple println! hooks in middleware methods to illustrate logging behavior.
- The run_app_with_frame test utility uses a fixed 1024-byte duplex buffer, which may not accommodate larger frames—consider making the buffer size configurable or increasing its default capacity.

## Individual Comments

### Comment 1
<location> `examples/echo.rs:9` </location>
<code_context>
+};
+
+struct Logger;
+impl Middleware for Logger {}
+
+#[tokio::main]
</code_context>

<issue_to_address>
Implement the required methods for the Middleware trait or explicitly document why the implementation is empty.

Leaving the Middleware implementation for Logger empty may be intentional, but it is best practice to either implement the required methods or add a comment explaining why the implementation is empty. This helps future maintainers understand the intent.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread examples/echo.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a81e2d8 and eb072a5.

📒 Files selected for processing (3)
  • examples/echo.rs (1 hunks)
  • tests/routes.rs (1 hunks)
  • tests/util.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-test
  • GitHub Check: Analyze (actions)
🔇 Additional comments (4)
tests/util.rs (1)

13-27: Well-designed test utility function.

The implementation is solid with proper async handling, error propagation, and clear documentation of panic conditions. The use of duplex streams for in-memory testing is appropriate and efficient.

examples/echo.rs (1)

8-9: Empty middleware implementation is acceptable for examples.

The minimal Logger middleware implementation is appropriate for demonstrating the middleware pattern in an example.

tests/routes.rs (2)

18-25: Well-defined test data structures.

The TestEnvelope and Echo structs are properly defined with the necessary bincode traits for serialisation and deserialisation.


44-54: Proper message serialisation and framing.

The test correctly demonstrates the serialisation and framing process using the BincodeSerializer and LengthPrefixedProcessor.

Comment thread examples/echo.rs Outdated
Comment thread tests/routes.rs
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 20, 2025

@sourcery-ai review

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jun 20, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes - here's some feedback:

  • The run_app_with_frame helper only drives a single request–response; consider extending it to handle multiple frames so tests can simulate streaming or pipelined interactions.
  • In the echo.rs example the Logger middleware is a no-op—either implement a simple log hook to show how wrap works or remove the unused stub for clarity.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `run_app_with_frame` helper only drives a single request–response; consider extending it to handle multiple frames so tests can simulate streaming or pipelined interactions.
- In the `echo.rs` example the `Logger` middleware is a no-op—either implement a simple log hook to show how `wrap` works or remove the unused stub for clarity.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@leynos leynos merged commit c522d2e into main Jun 20, 2025
5 checks passed
@leynos leynos deleted the codex/create-echo-server-example-with-tests branch June 20, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant