tetratelabs / wazero

wazero: the zero dependency WebAssembly runtime for Go developers
https://wazero.io
Apache License 2.0
4.74k stars 246 forks source link

Plans to support component model? #2200

Closed purplefox closed 3 months ago

purplefox commented 3 months ago

Hi All,

Sorry for using an issue to ask a question, but didn't know how else to do this.

I started using wazero recently as a way to run custom functions in the database we are building. My experience so far is very positive!

Do you have plans to support component model, so we can have a standard, non custom way to pass complex types (strings, byte arrays etc) to and from wasm modules? Any timeline for this?

evacchi commented 3 months ago

We currently do not have sharable roadmaps in this regard.

mathetake commented 3 months ago

sorry the answer is definitely no until it is standardized in the w3c recommendation, which I don't think will happen in at least for the next 5 years or so.

purplefox commented 3 months ago

Thanks for your replies.

In the absence of component model support in the foreseeable future, do you have any other approach in mind for making it easier to support complex parameter types? For Rust/Go its not so bad as we can malloc/free in the module do unsafe casts to memory but this isn't possible in all languages that have WASM support, thus making them pretty much unusable for use cases such as user defined functions running in a database (unless all params are int/float which is extremely restrictive)

evacchi commented 3 months ago

usually people provide a form of SDK and hide the serialization routines from the end users. Some approaches I have seen in the wild are based e.g. on protobuf (although generated code tends to be large) for instance see https://github.com/knqyf263/go-plugin or other serialization formats. If performance is not an issue I personally have used JSON because all languages have built-in support for it (especially on POCs)

Also, you might want to checkout Extism, their Go runtime is based on wazero. Their solution is probably a bit more opinionated than just a library, but it might be a good fit depending on your workload; personally I like it https://extism.org/docs/concepts/host-sdk