Conversation
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
✨ 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 (
|
Reviewer's GuideThis PR enhances WireframeApp by introducing per-connection lifecycle hooks: it generalizes the app to track connection-specific state, provides builder methods to register async setup and teardown callbacks, invokes these hooks in the connection handler, and updates documentation and tests accordingly. Sequence diagram for connection lifecycle with setup and teardown hookssequenceDiagram
participant Client
participant WireframeApp
participant SetupCallback as on_connect
participant TeardownCallback as on_disconnect
Note over Client,WireframeApp: New connection established
Client->>WireframeApp: Initiate connection
alt on_connect is registered
WireframeApp->>SetupCallback: Call on_connect()
SetupCallback-->>WireframeApp: Return connection state (C)
else on_connect not registered
WireframeApp-->>WireframeApp: No connection state
end
Note over Client,WireframeApp: ...connection handled...
Note over Client,WireframeApp: Connection closing
alt on_disconnect is registered and state exists
WireframeApp->>TeardownCallback: Call on_disconnect(state)
TeardownCallback-->>WireframeApp: Complete
else on_disconnect not registered or no state
WireframeApp-->>WireframeApp: No teardown
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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> `src/app.rs:175` </location>
<code_context>
+ ///
+ /// This function always succeeds currently but uses [`Result`] for
+ /// consistency with other builder methods.
+ pub fn on_connection_setup<F, Fut, C2>(self, f: F) -> Result<WireframeApp<S, C2>>
+ where
+ F: Fn() -> Fut + Send + Sync + 'static,
</code_context>
<issue_to_address>
on_connection_setup replaces the connection state type, which may be surprising in a builder chain.
Document that on_connection_setup changes the connection state type parameter, or consider making this type transition more explicit in the API.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
/// Register a callback invoked when a new connection is established.
///
/// The callback can perform authentication or other setup tasks and
/// returns connection-specific state stored for the connection's
/// lifetime.
///
/// # Errors
///
/// This function always succeeds currently but uses [`Result`] for
/// consistency with other builder methods.
pub fn on_connection_setup<F, Fut, C2>(self, f: F) -> Result<WireframeApp<S, C2>>
=======
/// Register a callback invoked when a new connection is established.
///
/// The callback can perform authentication or other setup tasks and
/// returns connection-specific state stored for the connection's
/// lifetime.
///
/// # Type Parameters
///
/// This method changes the connection state type parameter from `C` to `C2`.
/// This means that any subsequent builder methods will operate on the new connection state type `C2`.
/// Be aware of this type transition when chaining builder methods.
///
/// # Errors
///
/// This function always succeeds currently but uses [`Result`] for
/// consistency with other builder methods.
pub fn on_connection_setup<F, Fut, C2>(self, f: F) -> Result<WireframeApp<S, C2>>
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/app.rs:26` </location>
<code_context>
/// without enforcing an ordering. Methods return [`Result<Self>`] so
/// registrations can be chained ergonomically.
-pub struct WireframeApp<S: Serializer = BincodeSerializer> {
+#[allow(clippy::type_complexity)]
+pub struct WireframeApp<S: Serializer = BincodeSerializer, C: Send + 'static = ()> {
routes: HashMap<u32, Service>,
</code_context>
<issue_to_address>
Function attribute is placed before the doc comment; attributes must come after the doc comment.
Please move the #[allow(clippy::type_complexity)] attribute below the doc comment for the struct, as per the style guide.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /// without enforcing an ordering. Methods return [`Result<Self>`] so | ||
| /// registrations can be chained ergonomically. | ||
| pub struct WireframeApp<S: Serializer = BincodeSerializer> { | ||
| #[allow(clippy::type_complexity)] |
There was a problem hiding this comment.
issue (review_instructions): Function attribute is placed before the doc comment; attributes must come after the doc comment.
Please move the #[allow(clippy::type_complexity)] attribute below the doc comment for the struct, as per the style guide.
Review instructions:
Path patterns: **/*.rs
Instructions:
Ensure that function attributes are placed AFTER the function doc comment
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Summary
on_connection_setupandon_connection_teardowntoWireframeAppTesting
cargo clippy -- -D warningsRUSTFLAGS="-D warnings" cargo testmdformat-allmarkdownlint --fixhttps://chatgpt.com/codex/tasks/task_e_685298a3ccf08322854ccf21ec5e7ac7
Summary by Sourcery
Implement connection lifecycle hooks in WireframeApp to support asynchronous setup and teardown with per-connection state
New Features:
Enhancements:
Documentation:
Tests: