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 <rvolosatovs@riseup.net>
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 <rvolosatovs@riseup.net>
|
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 <rvolosatovs@riseup.net>
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 <rvolosatovs@riseup.net>
…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 <rvolosatovs@riseup.net>
Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com>
|
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 <rvolosatovs@riseup.net>
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 <rvolosatovs@riseup.net>
Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com>
…isten`, and provide guidance on how implementations may handle them.
… of `connect` & `listen` even further.
…hen they're done, whereas UDP packets should be able to fail/succeed independently without affecting the transmission of other packets. Without the stream parameter and return value, the `transfer` method is beginning to look an afwul lot like `connect` again, so we might as well call it that.
…tion of ComponentModel-level subtyping of value types, so that we could add additional fields (e.g. TTL, TOS, etc.) without breaking backwards-compatibility. AFAIK, that idea has been put on hold indefinitely, so we might as well make the 0.3.0 interface as simple as possible
|
Hi,
As before, let me know what you think! |
|
I think this looks good. Especially, since this is still meant to be a draft, I'd prefer validating this API by implementing it in a runtime (Wasmtime) and a component. |
|
Alright, I think this is already more than good enough for the first draft, so I'm going to merge it now. |
* feat: add `wasi-0.3.0` draft
Followed the example of `wasi-http` and `wasi-clocks` duplicating the
package in a subdirectory
- Remove `would-block` 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
- Merge `read{,via-stream}` into a singular `read`. Both functions take
an offset as a parameter and since they now return `stream<u8>`,
callers can limit the amount of bytes read by using the `stream<u8>`
directly, therefore functionality of both is identical
- Merge `write{,via-stream}` into a singular `write`. Both functions take
an offset and `stream<u8>` as a parameter.
It is assumed that `error-context` returned by writes to the stream and
reads from the stream are sufficient for error handling.
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: avoid introspecting `error-context`
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 <rvolosatovs@riseup.net>
* chore: bump `@since` to `0.3.0`
#164 (comment)
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): simplify error handling
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): asyncify `read-directory`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: update wit-deps to 0.5.0
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* drop `-draft` version suffix
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 <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: add `wasi-0.3.0` draft
Followed the example of `wasi-http` and `wasi-clocks` duplicating the
package in a subdirectory
- Remove `would-block` 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
- Merge `read{,via-stream}` into a singular `read`. Both functions take
an offset as a parameter and since they now return `stream<u8>`,
callers can limit the amount of bytes read by using the `stream<u8>`
directly, therefore functionality of both is identical
- Merge `write{,via-stream}` into a singular `write`. Both functions take
an offset and `stream<u8>` as a parameter.
It is assumed that `error-context` returned by writes to the stream and
reads from the stream are sufficient for error handling.
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor: avoid introspecting `error-context`
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 <rvolosatovs@riseup.net>
* chore: bump `@since` to `0.3.0`
WebAssembly/wasi-filesystem#164 (comment)
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): simplify error handling
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* refactor(0.3): asyncify `read-directory`
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* feat: update wit-deps to 0.5.0
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
* drop `-draft` version suffix
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 <rvolosatovs@riseup.net>
---------
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
refs Ship WASIp3
Followed the example of
wasi-httpandwasi-clocksduplicating the package in a subdirectoryThis vendors
wasi-clocksfrom WebAssembly/wasi-clocks#77start-X/finish-Xfunction pairs byXwould-blockerror codenot-in-progresserror codewasi:io/error.errorusage byerror-contextwasi:io/streams.input-streamreturn values bystream<u8>in return positionwasi:io/streams.output-streamreturn values bystream<u8>in parameter position - Guests should be able to rely onstream.newto construct streams