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

rust/python: Ability to clear session #211

Merged

Conversation

amacneil
Copy link
Contributor

@amacneil amacneil commented Feb 12, 2025

Changelog

Add server.clear_session() method to Rust and Python

Docs

None

Description

Builds on top of #196, since it perfectly demonstrated the problem.

Discussion: Are we happy with server.clear_session()? I also thought about server.reset_session(), but I feel like "clear" is a bit more obvious to the user why you would call this. Any other suggestions?

Maybe it should be plural, server.clear_sessions()? Or maybe just server.clear()?

Copy link

linear bot commented Feb 12, 2025

@amacneil amacneil requested review from eloff, bryfox and gasmith February 12, 2025 21:11
@amacneil amacneil marked this pull request as ready for review February 12, 2025 21:11
@amacneil amacneil changed the title Rust/Python: Ability to reset/clear session Rust/Python: Ability to clear session Feb 12, 2025
Base automatically changed from gasmith/ws-stream-mcap to main February 12, 2025 21:35
Copy link
Contributor

Is there more than one session? Why would it be plural? If there are multiple connections I could see that. reset session seems like it would be the "most aligned" with a sessions concept for recordings and tracking recordings over time if you did rolling record. Might want to think about it in the context of mcap logging as well as the live connection we already support.

@amacneil
Copy link
Contributor Author

There is only one "session" in the context of the protocol, but there can be multiple clients, which a layperson might consider a session.

I'm not sure what the mcap equivalent would be - probably closing the file and starting a new one, but that seems out of scope.

Copy link
Contributor

The "robot sessions" concept seems relevant to consider here if you want to use the word "session". This is a function on the server which is separate - yes - and seems fine as you propose but might be useful to think about how it will or won't be confusing if we later introduce a higher-level "session" or "run" concept.

@amacneil amacneil changed the title Rust/Python: Ability to clear session rust/python: Ability to clear session Feb 12, 2025
@amacneil
Copy link
Contributor Author

True. What about just server.clear()?

@eloff
Copy link
Contributor

eloff commented Feb 12, 2025

Discussion: Are we happy with server.clear_session()? I also thought about server.reset_session(), but I feel like "clear" is a bit more obvious to the user why you would call this. Any other suggestions?

Maybe it should be plural, server.clear_sessions()? Or maybe just server.clear()?

Maybe clear_client_sessions() or reset_client_sessions()? The name is ok as-is.

Copy link
Contributor

@eloff eloff left a comment

Choose a reason for hiding this comment

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

One line of code to delete, otherwise LGTM. I'm still unsure on the name.

clear() seem to generic. I like clear_session more. I think it can stay as-is.

rust/foxglove/src/websocket.rs Outdated Show resolved Hide resolved
@@ -69,13 +69,16 @@ fn main() -> Result<()> {
let summary = Summary::load_from_mcap(&args.file)?;

info!("Waiting for client");
std::thread::sleep(Duration::from_secs(5));
std::thread::sleep(Duration::from_secs(1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Everybody's in such a gosh-darned rush.

We could also just skip the sleep when the --loop argument is provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤣 I wasn't sure what this was even for. but I already have my client up and was restarting the server a bunch so the sleep was annoying

Copy link
Contributor

Choose a reason for hiding this comment

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

It was for the non-looping case, where you want to wait a moment for the client to get connected and subscribe to channels after starting the server, but before transmitting the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Could we make it wait up to 5 seconds for a client to connect, but if a client connects then start streaming immediately?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that'd be nice. When I initially wrote it, we didn't have the callbacks for that, but we do now.

@amacneil amacneil merged commit d5391f3 into main Feb 12, 2025
28 checks passed
@amacneil amacneil deleted the adrian/fg-10462-easy-way-to-clear-screen-reset-session-id branch February 12, 2025 23:09
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.

4 participants