-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add "Clear" function to Speak Websocket clients #282
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request adds a new Changes
Sequence Diagram(s)sequenceDiagram
participant C as WebSocket Client (WSCallback/WSChannel)
participant S as Server
C->>S: WriteJSON({ "type": "Clear" })
alt Successful write
S-->>C: Acknowledgment (or success indication)
else Write failure
S-->>C: Error response
end
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
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 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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
pkg/client/speak/v1/websocket/client_channel.go (1)
170-186
: Consider tracking clear operations.The implementation looks good and follows the established patterns. However, consider tracking clear operations similar to how flush operations are tracked using
flushCount
. This would provide consistency in operation monitoring.Apply this diff to add clear operation tracking:
func (c *WSChannel) WriteJSON(playload controlMessage) error { if playload.Type == MessageTypeFlush { c.muFinal.Lock() c.flushCount++ klog.V(5).Infof("Flush Count: %d\n", c.flushCount) c.muFinal.Unlock() + } else if playload.Type == MessageTypeClear { + c.muFinal.Lock() + c.clearCount++ + klog.V(5).Infof("Clear Count: %d\n", c.clearCount) + c.muFinal.Unlock() } return c.WSClient.WriteJSON(playload) }pkg/client/speak/v1/websocket/client_callback.go (1)
171-187
: Consider tracking clear operations.The implementation looks good and follows the established patterns. However, consider tracking clear operations similar to how flush operations are tracked using
flushCount
. This would provide consistency in operation monitoring.Apply this diff to add clear operation tracking:
func (c *WSCallback) WriteJSON(playload controlMessage) error { if playload.Type == MessageTypeFlush { c.muFinal.Lock() c.flushCount++ klog.V(5).Infof("Flush Count: %d\n", c.flushCount) c.muFinal.Unlock() + } else if playload.Type == MessageTypeClear { + c.muFinal.Lock() + c.clearCount++ + klog.V(5).Infof("Clear Count: %d\n", c.clearCount) + c.muFinal.Unlock() } return c.WSClient.WriteJSON(playload) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pkg/client/speak/v1/websocket/client_callback.go
(1 hunks)pkg/client/speak/v1/websocket/client_channel.go
(1 hunks)pkg/client/speak/v1/websocket/constants.go
(1 hunks)
🔇 Additional comments (1)
pkg/client/speak/v1/websocket/constants.go (1)
30-32
: LGTM!The new constant follows the established naming convention and documentation style.
Proposed changes
Adds a function that will call the Clear command message on the Speak channel and callback websocket clients.
This functionality already appears to work using
WriteJSON
with Type as Clear, this change is just a helper function to codify that (as has been done for Flush, Reset, etc)Types of changes
What types of changes does your code introduce to the community Go SDK?
Checklist
Summary by CodeRabbit