extism / go-sdk

Extism Go SDK - easily run WebAssembly modules in your Go applications
https://pkg.go.dev/github.com/extism/go-sdk
BSD 3-Clause "New" or "Revised" License
85 stars 10 forks source link

feat: Enable adding custom host functions in the `env` module #4

Closed mhmd-azeez closed 1 year ago

mhmd-azeez commented 1 year ago

By default, Go (and some other languages) expects imports to be from the env namespace. This creates a problem for us because each Wazero runtime can only have only one env module at a time and we can't modify modules once we initialize them. We don't have this problem in wasmtime because the Linker allowed us to register host functions in any module we wanted without having to create a special host module

The only solution I could think of is to create a Wazero runtime per plugin. This way, when creating the env module, we can also register the custom host functions.

mhmd-azeez commented 1 year ago

Keeping the two PRs in sync is a lot of work, will merge this and we can change things in #1 if necessary

nilslice commented 1 year ago

Keeping the two PRs in sync is a lot of work, will merge this and we can change things in #1 if necessary

Sorry for the delay in review - been difficult to get enough dedicated time while traveling! After today I should be able to help much more. Thank you for being proactive here!

mhmd-azeez commented 1 year ago

@nilslice no worries, looking forward to your review!