Stream: general

Topic: Building a Reactor with `cargo wasi`


view this post on Zulip Marco Buono (Sep 28 2021 at 17:26):

Hey there :wave: I'm wondering, what is the proper way of building a "reactor"-style wasm module with cargo wasi? I found some discussions around -Zwasi-exec-model, but from my understanding, that seems to require cargo Nightly to work... Is there a "sanctioned" way of enabling that that doesn't require nightly or is this still a somewhat new area that is still in flux?

view this post on Zulip Dan Gohman (Sep 28 2021 at 17:30):

I'm not sure what the current status is; the big picture is that the "reactor" concept has been folded into the interfaces types and module linking proposals, so the whole space is in flux while those proposals advance.

view this post on Zulip fitzgen (he/him) (Sep 28 2021 at 17:46):

you can use a cdylib crate-type and then export individual functions, for now

view this post on Zulip fitzgen (he/him) (Sep 28 2021 at 17:47):

see https://doc.rust-lang.org/cargo/reference/cargo-targets.html#library

view this post on Zulip Marco Buono (Sep 28 2021 at 18:07):

Oh. Interesting, thanks! Good thing I asked before trying out some kludge to make it work :relieved: I'll try the cdylib approach, does that still allow for an initializer? Or do I need to implement it manually?

view this post on Zulip Marco Buono (Sep 28 2021 at 18:10):

Also, the reason why I wanted a reactor in the first place was to allow each instance to handle incoming events in a (host) async task in an executor... I guess other option would maybe be using the async feature to make the WASM instance "own" it's own event loop, but be suspended/await on its message queue every time it calls the parent to receive new messages?

view this post on Zulip fitzgen (he/him) (Sep 28 2021 at 18:10):

You can implement it manually


Last updated: Nov 22 2024 at 16:03 UTC