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

feat: add the WatchState API #582

Merged
merged 11 commits into from
Nov 5, 2024

Conversation

Rustin170506
Copy link
Collaborator

@Rustin170506 Rustin170506 commented Sep 5, 2024

close #551
close #567

This pull request introduces a new stream API named "WatchState." Currently, it only provides the current temporality, which will enable clients to check if the server has been paused.

See more: #567 (comment)

Screen.Recording.2024-10-26.at.17.18.50.mov

@Rustin170506
Copy link
Collaborator Author

@hds Do you have time to take a quick look at this pull request before I continue? I want to ensure I'm on the right track and understand your feedback correctly.

Do you have any thoughts on how to use it with tokio-console? Currently, we use next_update to connect to the server and handle all the backoff stuff. I'm not sure how to use this new API in tokio-console. I'm unsure which step we should take first when we're trying to start the client. Perhaps we should watch the stats first? Or should we only watch the stats after we receive the first update?

@hds
Copy link
Collaborator

hds commented Sep 10, 2024

@Rustin170506 I think this is the right approach.

To integrate this with Tokio-Console, I would get the State stream from WatchState and include it in the tokio::select! statement in main():

tokio::select! { biased;

To make the UI "reactive" even in the event of network slow down, we may want to have some additional states in Tokio Console for "pausing" and "unpausing" which would be set in between the user pressing the space bar and the new state being received from the State stream.

Does that make sense?

@Rustin170506
Copy link
Collaborator Author

To integrate this with Tokio-Console, I would get the State stream from WatchState and include it in the tokio::select! statement in main():

The issue at hand is that when we call next_event, it attempts to connect to the server within the function. However, since we've introduced a new API, we're unsure about when we should monitor this new API. Should we have next_event establish the connection first, or should we update the logic to monitor the state API and establish the connection simultaneously?

@hds
Copy link
Collaborator

hds commented Sep 12, 2024

My thought was to do it all simultaneously.

@Rustin170506 Rustin170506 marked this pull request as ready for review October 24, 2024 14:47
@Rustin170506 Rustin170506 requested a review from a team as a code owner October 24, 2024 14:47
@Rustin170506 Rustin170506 marked this pull request as draft October 24, 2024 15:12
Copy link
Collaborator Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506 Rustin170506 marked this pull request as ready for review October 26, 2024 09:20
@Rustin170506 Rustin170506 requested a review from hds October 26, 2024 09:20
@Rustin170506
Copy link
Collaborator Author

@hds, I finally have some time to fix it. Could you please take a look? Thank you!

Copy link
Collaborator

@hds hds left a comment

Choose a reason for hiding this comment

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

Everything is looking great!

I've got one suggestion regarding the user experience and a question regarding cancel safety.

tokio-console/src/state/mod.rs Show resolved Hide resolved
tokio-console/src/conn.rs Show resolved Hide resolved
Copy link
Collaborator Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506 Rustin170506 requested a review from hds November 2, 2024 06:41
Copy link
Collaborator

@hds hds left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you!

Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
@Rustin170506
Copy link
Collaborator Author

Rebaed to the latest master.

@Rustin170506 Rustin170506 merged commit 7c1f9f2 into tokio-rs:main Nov 5, 2024
18 checks passed
@github-actions github-actions bot mentioned this pull request Nov 5, 2024
@Rustin170506
Copy link
Collaborator Author

Thanks for your review! 💚 💙 💜 💛 ❤️

@Rustin170506 Rustin170506 deleted the rustin-patch-temporality branch November 9, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio-console cannot show the pause status correctly
2 participants