erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
887 stars 189 forks source link

Support for WASI #258

Closed skyne98 closed 5 years ago

skyne98 commented 5 years ago

Hey there, maybe you guys have heard about the new and shiny WebAssembly WASI standard?

I think it might be very useful to try to add WASI support to rust-zmq. However, I am not sure whether the IPC is supported at all, I am far from being an expert in low-level Linux system calling 😄.

Here are the WASI Core system APIs for reference.

Thanks for your time!

jedisct1 commented 5 years ago

WASI doesn't support network access yet.

You can have pre-opened sockets that a Wasm/WASI app could use, but the app itself cannot listen to a port, initiate a connection or exchange datagrams.

Even sending/receiving data on a preopened socket is not implemented by most runtimes because the way networking will be done in WASI still remains to be designed.

skyne98 commented 5 years ago

@jedisct1 thanks for the insight. What about IPC based communication?

jedisct1 commented 5 years ago

Same.

WebAssembly modules can communicate via their runtime, but there is no standardized interface yet.

skyne98 commented 5 years ago

It seems like a big problem for WASI. It seems to lack mechanisms for arbitrary extensions (Vulkan extensions, e.g.). That means that for every specific case the standard will have to be extended, as well as runtimes. That sounds really, really slow and problematic.

jedisct1 commented 5 years ago

Give it some time. WASI is still fairly new. Extension mechanisms are being discussed, but providing a consistent API across all runtimes comes with a lot of challenges.

skyne98 commented 5 years ago

Sure, its creators and contributors are making the dream come true at the moment. I acknowledge that there is still a lot of work to do, and we have to be patient or maybe even help. Also this is what I've been dreaming of since Webassembly was released. Gets me very, very excited about WASI.

rotty commented 5 years ago

Since rust-zmq is not a pure-Rust crate, but a binding to libzmq, the prerequisite would be to get libzmq itself to be able to be cross-compiled to WASM and runnable on WASI, which in turn needs UDP socket support in WASI to work.

Once someone can come up with a proof-of-concept application implemented in C, using libzmq directly , which actually runs in WASI, we can investigate support in rust-zmq.

This seems quite a premature feature request to me ;-).

skyne98 commented 5 years ago

@rotty thanks for your reply. Just wanted to put the idea out there, so if someone is interested in it, it can be discussed with slightly more qualified developers :smile:

I am constantly watching the changes being made to the standard, as well as runtime support for them. As it was mentioned, WASI code at the moment is only capable of reading and writing from/to open sockets, so i guess we are halfway there already!

rotty commented 5 years ago

I think I'll close this now. If someone comes up with a PoC, having a libzmq-based C demo app running on WASI, we can discuss this again in a new issue.

skyne98 commented 5 years ago

I agree :+1: