Optimize the code#3
Merged
Merged
Conversation
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
There was a problem hiding this comment.
Pull request overview
Despite the title "Optimize the code", this PR is primarily a feature/refactor change that introduces WebSocket subprotocol versioning (sandd.v1) between the daemon client and the server, renames the public Python execute_command keyword from timeout_secs to timeout, and reduces noise in the heartbeat monitor log. It also tidies up trailing whitespace in docs/PROTOCOL.md and expands the simple command example to iterate over all daemons and test multiple commands.
Changes:
- Add WebSocket
Sec-WebSocket-Protocol: sandd.v1negotiation on both server (Axum handler) and daemon (tokio-tungstenite client request), with docs inPROTOCOL.md. - Rename the public Python
execute_commandparametertimeout_secs→timeoutin PyO3 binding, Python wrapper, README, and the example script (wire protocol fieldtimeout_secsis unchanged). - Simplify the heartbeat monitor log to only show
registry.count(), and reorder route registration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/server.rs | Adds HeaderMap + subprotocol negotiation in websocket_handler; simplifies heartbeat log; reorders /stats and /health routes. |
| server/src/lib.rs | Renames PyO3 keyword timeout_secs → timeout; still serializes to wire field timeout_secs. |
| sandd/src/main.rs | Builds a manual IntoClientRequest to send Sec-WebSocket-Protocol: sandd.v1, and logs the negotiated protocol from the response. |
| python/sandd/init.py | Updates execute_command signature and docstring to use timeout. |
| README.md | Updates example to use timeout= kwarg. |
| examples/simple_command_test.py | Iterates over all daemons and runs multiple test commands (success, intentional error, echo). |
| docs/PROTOCOL.md | Documents subprotocol versioning; strips trailing whitespace on Direction lines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #
Special notes for your reviewer
Does this PR introduce a user-facing change?