-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update to WIT-enabled wasmCloud #605
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I think there are some opportunities to rename some things to be more clear and disambiguated.
Also I can't tell from mobile but make sure all the integration tests pass on these new nif changes
@@ -10,8 +10,7 @@ path = "src/lib.rs" | |||
crate-type = ["dylib"] | |||
|
|||
[dependencies] | |||
# Patched temporarily to fix TinyGo modules, branch will be removed in v0.63.0 | |||
wasmcloud = { git = "https://github.com/wasmcloud/wasmcloud", branch = "fix/0.62-tinygo"} | |||
wasmcloud-host = { git = "https://github.com/rvolosatovs/wasmcloud", branch = "feat/wit"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this wasmCloud host is confusing as there is a full elixir project in this repo called wasmCloud host (the washboard).
Also, we shouldn't be depending on your fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a draft and the fork is used precisely because wasmCloud/wasmCloud#300 is not merged yet. There's nothing else to depend upon to get this up
} | ||
|
||
#[derive(Clone)] | ||
struct ElixirHandlerArc(Arc<ElixirHandler>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know naming is hard but I'd rather not put a data type like arc as a suffix on a struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you suggest a better option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was called ElixirHandler before. The fact that the inner element is an arc shouldn't be advertised in the name.
You could call it a handler reference or elixir handler reference.. just something that doesn't have a data type in the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what would the inner struct be called then? ElixirHandlerInner
? I really don't see how that's better.
The only option to avoid this is to store an unnamed tuple in an Arc, but that'd be very difficult to maintain and use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not sure what caused the need for the arc wrapper around the elixir handler. Since I'm on a phone deferring to Taylor for thoughts on the abstraction and name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what caused the need for the arc wrapper around the elixir handler
Mainly, wasmtime/wit-bindgen design drawbacks, namely the fact that the host trait implementations take &mut self
parameter, therefore forcing this pattern on us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But shouldn't we be insulating consumers of our rust wasmCloud library from design changes and decisions of the underlying libraries? We shouldn't have to refactor the otp nif every time wasmtime makes an internal change... Isolating the host from this kind of churn is actually the primary purpose of the rust wasmCloud library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what caused the need for the arc wrapper around the elixir handler
Mainly, wasmtime/wit-bindgen design drawbacks, namely the fact that the host trait implementations take
&mut self
parameter, therefore forcing this pattern on us
If they force this on our wasmCloud library then the wasmCloud library should not pass this along to its consumers. It is designed specifically to prevent this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, eventually we should think about this, depending on the state of things in the future - right now it's way too early to build these abstractions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. Our job with libwasmcloud is to isolate consumers from wasmtime and its volatility. It's our job to come up with a more stable abstraction than the raw wasmtime interface.
Bottom line: if we have to refactor the nif every time wasmtime changes an API, then libwasmcloud is not doing its job. |
Again, that comes in the future. We will reach this point some day, but now is not the right time to build these abstractions (just like the handler abstraction API was prematurely built earlier and replaced here). It's much more dangerous and costly to build the wrong abstraction, rather than pay a minuscule cost of changing a few lines of code very infrequently (if at all). Please note that "libwasmcloud" is not even Making sure these interfaces (WIT traits, WASI etc.) are actually usable and backwards compatible is Wasmtime/Bytecode Alliance's job, not ours. What changes are you afraid of? Eventually, the "Arc" trick will not be necessary anymore - the (wit-bindgen generated) traits should take Next, there's the question of WIT interfaces being updated - e.g. a new method is added. Again, this maintenance burden belongs upstream - it's upstream's job to ensure backwards compatibility, e.g. ensure there are default implementations for any new methods added. If upstream fails it's job and introduces breaking changes, then that's the point where we can abstract these traits ourselves, i.e. instead of reexporting |
@rvolosatovs looks like we've gone through a few changes but settled that this PR is something we should do, would you mind providing a status update here on if this should stay draft, be replaced by another PR, etc? |
I think we should keep this until https://github.com/wasmCloud/wasmcloud has reached 0.1 or there are features we explicitly need from the library and then get back to this and update to recent changes. We don't get anything by doing this now, but there's a lot of work that will be useful once we do |
We don't get anything by doing this now, but there's a lot of work that will be useful once we do Don't we get the ability for the OTP host to execute modules and components built using the latest standards? |
d3200fa
to
2a7e47c
Compare
The version of |
Signed-off-by: Roman Volosatovs <[email protected]>
Thanks for the provider-archive bump 👍 |
@rvolosatovs when can this be taken out of draft and made ready to merge so we can use the new dependencies? |
the NIF segfaults on startup, someone has to debug and fix that, I can take a look tomorrow, but if you can figure out the issue, then please go ahead |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this has been closed too eagerly, please feel free to tag a maintainer so we can keep working on the issue. Thank you for contributing to wasmCloud! |
Feature or Problem
Update to NIF to wasmCloud/wasmCloud#300
Related Issues
wasmCloud/wasmCloud#300
Release Information
Consumer Impact
Testing
Built on platform(s)
Tested on platform(s)
Unit Test(s)
Acceptance or Integration
Manual Verification