-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: cleanup processing of websocket packets #24
Conversation
- remove unreachable code that checked type of data since invalid dta already rases in the WSPacket class - cache the result of the WSPacket properties - avoid many dict lookups in the websocket data processing - avoid creating enums in the websocket packet processing
WalkthroughThe recent modifications primarily focus on enhancing the functionality and performance of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Bootstrap
participant WSPacket
Client ->> Bootstrap: Initialize Bootstrap instance
Bootstrap ->> WSPacket: Receive WebSocket data
WSPacket -->> Bootstrap: Parse data with cached properties
Bootstrap ->> Bootstrap: Process WebSocket packet
Bootstrap -->> Client: Return processed data
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
|
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.
Actionable comments posted: 1
Outside diff range and nitpick comments (1)
src/uiprotect/data/websocket.py (1)
186-186
: Add a docstring to the__init__
method to improve code documentation.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/uiprotect/data/bootstrap.py (3 hunks)
- src/uiprotect/data/websocket.py (5 hunks)
Additional context used
GitHub Check: codecov/patch
src/uiprotect/data/bootstrap.py
[warning] 550-550: src/uiprotect/data/bootstrap.py#L550
Added line #L550 was not covered by tests
[warning] 586-586: src/uiprotect/data/bootstrap.py#L586
Added line #L586 was not covered by tests
Additional comments not posted (3)
src/uiprotect/data/websocket.py (2)
Line range hint
196-206
: The use ofcached_property
foraction_frame
anddata_frame
is a good optimization to avoid redundant decoding.Also applies to: 206-227
226-227
: Ensure that the cache invalidation in theraw
setter method is effective by testing edge cases whereraw
data changes frequently.src/uiprotect/data/bootstrap.py (1)
171-173
: The addition of_ModelType_NVR_value
and_ModelType_Event_value
as class-level constants is a good practice for maintainability and readability.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/uiprotect/data/websocket.py (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/uiprotect/data/websocket.py
Description of change
WSPacket
classWSPacket
propertiesklass_from_format
since the inputs are almost all the sameSummary by CodeRabbit
Refactor
Bug Fixes