-
Notifications
You must be signed in to change notification settings - Fork 24
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: add wasi-0.3.0
draft
#111
base: main
Are you sure you want to change the base?
Conversation
605a6b4
to
92f2c42
Compare
Followed the example of `wasi-http` and `wasi-clocks` duplicating the package in a subdirectory - In wasip3 return values of functions are pollable by guests, therefore remove abstractions for which there is no need anymore: - Replace `start-X`/`finish-X` function pairs by `X` - Remove `would-block` error code - Remove `not-in-progress` error code - Replace `wasi:io/error.error` usage by `error-context` - Replace `wasi:io/streams.input-stream` return values by `stream<u8>` in return position - Replace `wasi:io/streams.output-stream` return values by `stream<u8>` in parameter position - Guests should be able to rely on `stream.new` to construct streams Signed-off-by: Roman Volosatovs <[email protected]>
92f2c42
to
d0f8ab5
Compare
This seems to be better aligned with latest specification on error context https://github.com/WebAssembly/component-model/blob/cbdd15d9033446558571824af52a78022aaa3f58/design/mvp/Explainer.md#error-context-type > A consequence of this, however, is that components *must not* depend on the > contents of `error-context` values for behavioral correctness. In particular, > case analysis of the contents of an `error-context` should not determine > *error recovery*; explicit `result` or `variant` types must be used in the > function return type instead (e.g., > `(func (result (tuple (stream u8) (future $my-error)))`). Signed-off-by: Roman Volosatovs <[email protected]>
After reading the
@lukewagner perhaps you could confirm that the changes in that commit are moving in the direction you'd expect? |
WebAssembly/wasi-filesystem#164 (comment) Signed-off-by: Roman Volosatovs <[email protected]>
dfc429e
to
8a3b482
Compare
Yes, you're right about the direction; thanks for asking! Indeed, I'm not that familiar with wasi-sockets, but I wonder if we could simplify resource tcp-socket {
connect:func(n: borrow<network>, remote: ip-socket-address) -> result<tcp-connection, error-code>;
}
resource tcp-connection {
write: func(tx: stream<u8>) -> result<option<error-code>>;
read: func() -> result<tuple<stream<u8>, future<option<error-code>>>>;
} (where To wit, once we add read: func() -> result<stream<u8, option<error-code>> cc @dicej for any other thoughts |
Signed-off-by: Roman Volosatovs <[email protected]>
…oper streams with cancellation.
…ymore, `listen` is free to do an implicit bind again. Just like POSIX.
…of client sockets.
… already covers all its use-cases. Was an oversight in v0.2
…ymore, `stream` is free to do an implicit bind again. Just like POSIX.
Signed-off-by: Roman Volosatovs <[email protected]>
…imal, but now that streams are actually a thing, it was even more akward.
…i-sockets into pr/111 # Conflicts: # wit-0.3.0-draft/ip-name-lookup.wit
``` Error: failed to resolve directory while parsing WIT for path [wit-0.3.0-draft] Caused by: 0: failed to process feature gate for type [duration] in package [wasi:[email protected]] 1: feature gate cannot reference unreleased version 0.3.0 of package [wasi:[email protected]] (current version 0.3.0-draft) ```
Thanks @rvolosatovs for getting this off the ground! I have taken liberty to directly implement some of my suggestions, because doing it this way is hopefully faster than needing to type it all out upfront. Let me know what you think:
Also, since we're breaking compatibility, this seems like a good moment to freshen up the interface a bit. Even though wasi-sockets is technically a v0.2.0 interface, some aspects of were very much still designed with a v0.1.0 mindset. So:
Documentation updates:
Finally, I don't know if I'm missing some CLI flags or something, but for me wit-bindgen fails with:
I've changed the package version to make it happy. Don't know if this was the correct thing to do, but at least it works for me now :) I'm on Let me know what you think! |
Here and in similar functions in wasi-filesystem, I wonder if we could avoid the inner receive: func() -> result<tuple<stream<u8>, future<result<_, error-code>>>>; which could look like this instead: receive: func() -> result<tuple<stream<u8>, future<error-code>>>; The idea is, |
I was going back-and-forth on this one and I felt like perhaps a "future that may never resolve" is a concept harder to grasp for developers as opposed to a "future that always resolves to something". It also lets us avoid outer So I'd go for: receive: func() -> tuple<stream<u8>, future<result<_, error-code>>>; And soon: receive: nonblocking func() -> tuple<stream<u8>, future<result<_, error-code>>>; |
Co-authored-by: Roman Volosatovs <[email protected]>
The suggestion of @rvolosatovs seems the most natural to me:
especially since that may be shortened even further to:
depending on the progress of error-contexts |
Thanks @badeend, your changes look good to me, just left one comment. |
6a44e3c
to
2a47838
Compare
Signed-off-by: Roman Volosatovs <[email protected]>
2a47838
to
f646c25
Compare
This ensures that e.g.: ``` wit-bindgen markdown wit-0.3.0-draft -w imports --html-in-md ``` works with wit-bindgen 0.37 refs: WebAssembly/wasi-sockets@3abda6e refs: WebAssembly/wasi-sockets#111 (comment) Signed-off-by: Roman Volosatovs <[email protected]>
Co-authored-by: Roman Volosatovs <[email protected]>
refs https://github.com/orgs/bytecodealliance/projects/16?pane=issue&itemId=88153506
Followed the example of
wasi-http
andwasi-clocks
duplicating the package in a subdirectoryThis vendors
wasi-clocks
from WebAssembly/wasi-clocks#77start-X
/finish-X
function pairs byX
would-block
error codenot-in-progress
error codewasi:io/error.error
usage byerror-context
wasi:io/streams.input-stream
return values bystream<u8>
in return positionwasi:io/streams.output-stream
return values bystream<u8>
in parameter position - Guests should be able to rely onstream.new
to construct streams