Refactor app module into focused submodules#447
Conversation
… modules - Moved connection lifecycle builder methods (on_connection_setup, on_connection_teardown) into src/app/builder_lifecycle.rs - Moved protocol configuration builder methods (with_protocol, with_message_assembler, protocol, protocol_hooks) into src/app/builder_protocol.rs - Removed these methods from src/app/builder.rs - Updated mod.rs to include new modules - Added test fixture module for frame codec and reorganized tests These changes aim to improve code organization by separating concerns within the app builder. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Reviewer's GuideRefactors the Class diagram for shared test frame codec fixtureclassDiagram
class FrameCodec {
<<trait>>
+wrap_payload(payload)
+decoder()
+encoder()
+frame_payload(frame)
+correlation_id(frame)
+max_frame_length()
}
class TestFrame {
+u8 tag
+Vec_u8_ payload
}
class TestAdapter {
+usize max_frame_length
+decode(src)
+encode(item, dst)
}
class TestCodec {
+usize max_frame_length
+AtomicUsize counter
+new(max_frame_length)
+wraps()
+decoder()
+encoder()
+wrap_payload(payload)
+frame_payload(frame)
+correlation_id(frame)
+max_frame_length()
}
class CombinedCodec {
+new(decoder, encoder)
}
class ResponseContext {
+serializer
+framed
+fragmentation
+codec
}
FrameCodec <|.. TestCodec
TestAdapter ..> TestFrame : encodes_decodes
TestCodec o--> TestAdapter : uses
TestCodec --> TestFrame : produces
CombinedCodec o--> TestAdapter : wraps
ResponseContext --> FrameCodec : generic_over
ResponseContext --> CombinedCodec : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbitRelease Notes
WalkthroughThe PR decomposes src/app.rs by extracting builder methods into focused submodules: builder_lifecycle.rs for connection lifecycle management and builder_protocol.rs for protocol configuration. Test frame codec utilities are consolidated into src/test_helpers/frame_codec.rs with public re-exports. The public API surface remains accessible through module organisation rather than removal. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
src/testsmodule is only gated behind#[cfg(test)]whiletest_helpersuses#[cfg(any(test, feature = "test-helpers"))]; if these fixtures are meant to be reused like the other helpers, consider aligning the cfg so you don’t end up with two parallel, slightly different test-helper mechanisms. - In
src/tests/fixtures/mod.rsyou use a relative#[path = "../../../tests/fixtures/test_frame_codec.rs"], which is quite brittle to directory layout changes; consider moving the implementation intosrc/and importing it fromtests/(rather than the other way around) to avoid deep relative paths.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `src/tests` module is only gated behind `#[cfg(test)]` while `test_helpers` uses `#[cfg(any(test, feature = "test-helpers"))]`; if these fixtures are meant to be reused like the other helpers, consider aligning the cfg so you don’t end up with two parallel, slightly different test-helper mechanisms.
- In `src/tests/fixtures/mod.rs` you use a relative `#[path = "../../../tests/fixtures/test_frame_codec.rs"]`, which is quite brittle to directory layout changes; consider moving the implementation into `src/` and importing it from `tests/` (rather than the other way around) to avoid deep relative paths.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…src/test_helpers - Renamed and relocated test_frame_codec.rs to src/test_helpers/frame_codec.rs - Updated imports and references from test_frame_codec::TestCodec to test_helpers::TestCodec - Removed redundant test fixtures modules from src/tests/fixtures and tests/fixtures - Adjusted mod declarations in src/lib.rs and tests to reflect the new structure This change consolidates test codec fixtures into the test_helpers module for better code reuse and clarity. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
@coderabbitai Have the following now been resolved?
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 371 🏁 Script executed: Length of output: 1671 🏁 Script executed: Length of output: 225 🏁 Script executed: Length of output: 5001 🏁 Script executed: Length of output: 2175 🏁 Script executed: Length of output: 4429
The
The refactor successfully consolidated all test utilities under the existing |
Summary
src/app/to improve maintainability and keep individual module sizes small. Public API exports remain unchanged.Changes
src/app/builder_lifecycle.rs: connection lifecycle builders (on_connection_setup, on_connection_teardown).src/app/builder_protocol.rs: protocol configuration builders (with_protocol, with_message_assembler, message_assembler, protocol, protocol_hooks).src/app/mod.rsnow declares the new submodules and reuses existing builder logic via these focused modules.src/test_helpers/frame_codec.rsand re-exported undersrc/test_helpers.rsto support frame-handling tests.src/app/while keeping public API unchanged.Details
on_connection_setup: register a callback invoked when a new connection is established.on_connection_teardown: register a callback invoked when a connection is closed.with_protocol: install aWireframeProtocolimplementation.with_message_assembler: install aMessageAssemblerimplementation.message_assembler: query installedMessageAssembler.protocol: return installed protocol, if any.protocol_hooks: derive hooks from installed protocol or default no-op hooks.src/test_helpers/frame_codec.rsused by frame handling tests.Migration notes
WireframeAppbuilder APIs should continue to compile without changes.src/app/builder.rs, they are now organized under the new submodules (builder_lifecycleandbuilder_protocol).Test plan
cargo testto ensure all unit tests pass.◳ Generated by DevBoxer ◰
ℹ️ Tag @devboxerhub to ask questions and address PR feedback
📎 Task: https://www.devboxer.com/task/74c9a10a-b985-4a32-a5fd-2b0cd06e294c
📝 Closes #291