wasmerio / wasmer

🚀 The leading Wasm Runtime supporting WASIX and WASI
https://wasmer.io
MIT License
19.02k stars 813 forks source link

How to utilize networking within wasm #2555

Closed diclophis closed 3 years ago

diclophis commented 3 years ago

Summary

What support exists in wasmer (specifically the wasmer-ruby wrapper) to provide TCP/HTTP networking facilities to wasm modules?

I am intrigued with the notion of utilizing wasm as part of a user-definable ETL pipeline, however I have not identified the best way to "capture" the result of any compute performed inside of a wasm module.... My initial thought is, have the module read in a file, and write out a file (given there is some file system support), and then do the networking at the "host" layer before and after the module is invoked (pre-fetching the file for input, and sending the output file onward to subsequent systems in the pipeline)

jcaesar commented 3 years ago

Directly doing networking from inside wasm? Wasmer doesn't provide any functionality to do that, as far as I know. (WASI has some related function calls but wasmer leaves them unimplemented.) You can of course provide your own imports! that allow for that. (But I would question if it's appropriate for a user-defined step in an ETL pipeline to do user-defined network IO.)

the best way to "capture" the result of any compute performed inside of a wasm module....

Probably the most lightweight way is to have your wasmer functions return a pointer to the wasmer memory, which you then read from your ruby code. (I hope this is possible from ruby. For a Rust example, see here.)

have the module read in a file, and write out a file

That sounds heavy. But it's of course possible.

diclophis commented 3 years ago

@jcaesar ok thanks, your points seem reasonable.

jcaesar commented 3 years ago

(PS: Ruby also had the "return pointer from memory"-example.)