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 WebAssembly Client #61

Merged
merged 11 commits into from
Jun 23, 2021
Merged

Add WebAssembly Client #61

merged 11 commits into from
Jun 23, 2021

Conversation

ecton
Copy link
Member

@ecton ecton commented Jun 19, 2021

This pull request adds the ability for pliantdb-client to connect over WebSockets in WebAssembly. Closes #58.

  • Add proper error handling
  • Add ability to disconnect when all clients drop
  • Investigate unit testing Split off to Figure out unit tests for wasm client #63
  • Document any gotchas (not sure if there are any noteworthy).

The nice thing is that the example doesn't need any special includes for PliantDb to work, so there isn't anything special to document about project setup.

This implements a WebAssembly-compatible version of the client that
supports WebSockets.

Some error handling code needs to be handled. Currently, the client will
not reconnect after failing. Additionally, if all clients are dropped,
the connection does not disconnect.

Other than that, it should be fully functional. Need to investigate unit
testing and how to best launch a native server while testing in wasm.
This makes dropping safe regardless of if it was in a non-tokio context.
When building without websocket support, tokio is still used for it
JoinHandle.
I originally thought that I should try using select here, but after more
thought, it would just make this code harder to understand. The comment
may have predated a refactor -- my aversion to using try_join was only
when I was mapping a success to error failure to abort try_join early.
Select should be more clear in that situation. That doesn't describe
this location, however.
Originally I thought it made more sense to do things differently in
wasm, but it really didn't. Now connections aren't attempted until the
first request arrives, and whichever request causes the connection error
will get it returned to them. This makes it functionally equivalent to
the other platforms, even though everything is still driven though
callbacks.
There wasn't a clear shutdown signal being sent to the request reading
task, and disconnect errors weren't being handled properly. This fixes
all issues with disconnecting and reconnecting in wasm
@ecton ecton marked this pull request as ready for review June 23, 2021 04:22
@ecton ecton merged commit 1c2ba1e into main Jun 23, 2021
@ecton ecton deleted the wasm-client branch June 23, 2021 04:22
@ecton ecton added this to the v0.1.0-alpha.1 milestone Dec 15, 2021
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.

Add WASM support to Client
1 participant