-
Notifications
You must be signed in to change notification settings - Fork 0
Simplify polling logic in ConnectionActor #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify polling logic in ConnectionActor #171
Conversation
Reviewer's GuideRefactors polling in ConnectionActor by extracting a centralized next_event method using a biased tokio::select into an Event enum and updating poll_sources to dispatch based on Event, while improving documentation around event derivation and priority ordering. Sequence diagram for next_event and poll_sources interactionsequenceDiagram
participant CA as ConnectionActor
participant State as ActorState
participant Out as Vec<F>
participant Event
actor Tokio as tokio::select!
CA->>Tokio: next_event(state)
Tokio-->>CA: Event (Shutdown | High | Low | Response | Idle)
CA->>CA: match Event
alt Shutdown
CA->>CA: process_shutdown(state)
else High
CA->>CA: process_high(res, state, out)
else Low
CA->>CA: process_low(res, state, out)
else Response
CA->>CA: process_response(res, state, out)
else Idle
CA->>CA: (do nothing)
end
CA-->>Out: (frames appended as needed)
Class diagram for Event enum and ConnectionActor polling refactorclassDiagram
class Event {
<<enum>>
+Shutdown
+High(Option<F>)
+Low(Option<F>)
+Response(Option<Result<F, WireframeError<E>>>)
+Idle
}
class ConnectionActor {
+next_event(state: &ActorState) Event<F, E>
+poll_sources(state: &mut ActorState, out: &mut Vec<F>) Result<(), WireframeError<E>>
-high_rx
-low_rx
-response
-shutdown
+process_shutdown(state: &ActorState)
+process_high(res, state, out)
+process_low(res, state, out)
+process_response(res, state, out)
}
ConnectionActor --> Event : uses
ConnectionActor --> WireframeError : uses
ConnectionActor --> ActorState : uses
ConnectionActor --> F : generic
ConnectionActor --> E : generic
Event --> WireframeError : uses
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
📄 Source: CodeRabbit Inference Engine (AGENTS.md) List of files the instruction was applied to:
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (3)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
Event
only derivesDebug
Testing
make fmt
cargo clippy --all-targets --all-features -- -D warnings
make test
https://chatgpt.com/codex/tasks/task_e_68682513d49c8322a850cdcefb505f3b
Summary by Sourcery
Simplify the polling flow in ConnectionActor by extracting a unified event selection method, consolidating shutdown/high/low/response handling into an Event enum, and streamlining poll_sources matching on those events.
Enhancements: