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

refactor(client): unify ws ping/pong API with the server #1258

Merged
merged 14 commits into from
Dec 8, 2023

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Dec 6, 2023

This changes the clients to support a similar WebSocket ping/pong as the server which
was introduced in #1248

The PingConfig type is duplicated in the server and client but I'm fine with that for now.

After introducing Instant in code I realized that the ping/pong interval would panic in wasm and I have removed ping/pongs completely because gloo-net doesn't support that anyway.

The other solution is to use some other crates where instants/interval stream are supported but it's not worth the effort IMHO and I think there was some reason in JS land where it's not possible to have client-side initiated pings.

@niklasad1 niklasad1 requested a review from a team as a code owner December 6, 2023 17:25
@niklasad1 niklasad1 changed the title refactor(client): unify ws ping/pong api refactor(client): unify ws ping/pong API with the server Dec 6, 2023
@niklasad1 niklasad1 changed the title refactor(client): unify ws ping/pong API with the server WIP refactor(client): unify ws ping/pong API with the server Dec 7, 2023
@niklasad1 niklasad1 changed the title WIP refactor(client): unify ws ping/pong API with the server refactor(client): unify ws ping/pong API with the server Dec 7, 2023
core/Cargo.toml Outdated Show resolved Hide resolved
@niklasad1 niklasad1 mentioned this pull request Dec 8, 2023
if let Err(err) = sender.send_ping().await {
tracing::error!(target: LOG_TARGET, "Could not send ping frame: {err}");
break Err(Error::Custom("Could not send ping frame".into()));
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice to de-duplicate these bits :)

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

Looks solid to me; good job!

///
/// Such that the `inactive_limit` should be configured to longer than a single
/// WebSocket ping takes or it might be missed and may end up
/// terminating the connection.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Might be worth stating the default values

Copy link
Contributor

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

Nice one! 👍

@niklasad1 niklasad1 merged commit eca4223 into master Dec 8, 2023
11 checks passed
@niklasad1 niklasad1 deleted the na-unify-ping-pong-api branch December 8, 2023 16:51
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.

3 participants