Hey Maintainers,
I have created a fork of tarpc, that supports WASM clients. I'm curious what the apatite is for supporting such a PR, maybe with an experimental feature flag? I have a few forked repos that have it all working end to end, see the links below. The nice thing is that the changes aren't heavy for tarpc. It really is just a few shims for the std::time/tokio::time calls and enabling a dependency feature flag (WASM support for rand crate). The only issue is I'm not sure if the time shim library is being actively maintained, I plan to file an issue with that project and see if they would accept a PR. If they aren't actively maintaining the project I can fork it and maintain it since shims aren't a lot of work and I'd like to explore this approach in a project I'm working on.
Side note: I started this a couple of weeks back, so my code is targeting tarpc 0.22, however I did test it with 0.23 (See the other branch) and it appears to work fine (IE, it compiles). I couldn't test it since my client/server have a dependency that hasn't moved to tokio 0.3 yet.
tarpc fork:
master...john-hern:wasm_support
Notes: I'll likely move the SystemTimeExt trait/impl into the wasm-timer fork/PR and implement from/into on the SystemTime type.
wasm-timer fork:
tomaka/wasm-timer@master...john-hern:tokioShim
Notes: Nothing interesting here except the reimplementation of tokio's timeout API using the shims.
server/client example.
https://github.com/john-hern/tarpc-wasm-client-tcp-server-example
Notes:
The server is using tokio + ws_stream_tungstenite to create the byte stream/sink over a websocket.
The client is a yew application, using ws_stream_wasm wasm_bindgen (spawn_local).
There are probably some caveats with edge cases. For example, the time shims wont work in a web worker. There is an issue in web-sys to address this. Once it's fixed, it should be possible to use this code in a web worker. Also, since wasms are currently single threaded there are probably some perf concerns. I'm pretty sure other things may pop up.
Thoughts?
*edit: Had the wrong link for the wasm-timer fork.
Hey Maintainers,
I have created a fork of tarpc, that supports WASM clients. I'm curious what the apatite is for supporting such a PR, maybe with an experimental feature flag? I have a few forked repos that have it all working end to end, see the links below. The nice thing is that the changes aren't heavy for tarpc. It really is just a few shims for the std::time/tokio::time calls and enabling a dependency feature flag (WASM support for rand crate). The only issue is I'm not sure if the time shim library is being actively maintained, I plan to file an issue with that project and see if they would accept a PR. If they aren't actively maintaining the project I can fork it and maintain it since shims aren't a lot of work and I'd like to explore this approach in a project I'm working on.
Side note: I started this a couple of weeks back, so my code is targeting tarpc 0.22, however I did test it with 0.23 (See the other branch) and it appears to work fine (IE, it compiles). I couldn't test it since my client/server have a dependency that hasn't moved to tokio 0.3 yet.
tarpc fork:
master...john-hern:wasm_support
Notes: I'll likely move the SystemTimeExt trait/impl into the wasm-timer fork/PR and implement from/into on the SystemTime type.
wasm-timer fork:
tomaka/wasm-timer@master...john-hern:tokioShim
Notes: Nothing interesting here except the reimplementation of tokio's timeout API using the shims.
server/client example.
https://github.com/john-hern/tarpc-wasm-client-tcp-server-example
Notes:
The server is using tokio + ws_stream_tungstenite to create the byte stream/sink over a websocket.
The client is a yew application, using ws_stream_wasm wasm_bindgen (spawn_local).
There are probably some caveats with edge cases. For example, the time shims wont work in a web worker. There is an issue in web-sys to address this. Once it's fixed, it should be possible to use this code in a web worker. Also, since wasms are currently single threaded there are probably some perf concerns. I'm pretty sure other things may pop up.
Thoughts?
*edit: Had the wrong link for the wasm-timer fork.