Skip to content
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 publish_status and remove_status methods to WebSocketServer #192

Merged
merged 14 commits into from
Feb 11, 2025

Conversation

eloff
Copy link
Contributor

@eloff eloff commented Feb 6, 2025

Relatively simple PR to add support for publishing status messages to all connected clients, and removing them by list of ids.

WS Spec

Current Python implementation

One thing I did here is treat status messages the same as log messages, in that when the queue is full it will drop older messages from the data plane queue.

@eloff eloff requested review from bryfox and gasmith February 6, 2025 19:04
Copy link

linear bot commented Feb 6, 2025

Copy link
Contributor

@gasmith gasmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG in general, though I wonder about the use of the data plane channel.

self.data_plane_tx.try_send(message).unwrap_or_else(|err| {
tracing::warn!("Failed to send status to client {}: {err}", self.addr)
});
self.send_data_lossy(message, MAX_SEND_RETRIES);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether these should be sent over the control plane channel instead, so that we don't drop them. I presume status messages are relatively low-frequency and high-importance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think so given our discussion we had on slack about dropping messages and using status messages over control plane to notify that.

How about a mix? control_plane for warning and above, data plane for info?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems pretty reasonable, sure.

@@ -168,6 +168,22 @@ impl WebSocketServerHandle {
.await;
}

/// Publishes a status message to all clients.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add links to the ws-protocol spec for these.

Comment on lines 174 to 176
level: crate::websocket::StatusLevel,
message: impl Into<String>,
id: Option<impl Into<String>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's an optional argument, we might consider having the client construct the Status, and perhaps with a builder (imagine, e.g., Status::error("oh no").id("x")).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems slightly better, yes

@eloff eloff requested a review from gasmith February 10, 2025 21:59
Copy link
Contributor

@gasmith gasmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments. Looks good!

@@ -175,6 +174,18 @@ impl WebSocketServerHandle {
.await;
}

/// Publishes a status message to all clients.
/// https://github.com/foxglove/ws-protocol/blob/main/docs/spec.md#status
pub fn publish_status(&self, status: Status) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add these methods on the blocking handle too.

@eloff eloff merged commit edd6a82 into main Feb 11, 2025
27 checks passed
@eloff eloff deleted the dan/fg-10177-core-support-status-updates-from-user branch February 11, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants