Skip to content
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

Fill in more of README.md, add Luke Wagner to champions #51

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 83 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,89 @@

A proposed [WebAssembly System Interface](https://github.com/WebAssembly/WASI) API.

This proposal currently only contains the proposed Wit interfaces with light
explanation in comments; more work is necessary to fully document the proposal.
The Wit comments annotate where the proposed interface is expected to change in
the short term (for Preview2) once resources and handles are re-added to Wit,
and then after that (for Preview3) once native stream support is added to the
Component Model and Wit.

The `wit` directory currently validates and can generate bindings with:
### Current Phase

wasi-http is currently in [Phase 1](https://github.com/WebAssembly/WASI/blob/main/Proposals.md#phase-1---feature-proposal-cg).

### Champions

* Piotr Sikora
* Jiaxiao Zhou
* Dan Chiarlone
* David Justice
* Luke Wagner

### Phase 4 Advancement Criteria

WASI-http must have at least two complete independent implementations. One
implementation must execute in a browser and may be implemented in terms of the
[Fetch API] using JavaScript. The other implementation must be implemented

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say FetchEvent ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. The Fetch API (specified here) is for outgoing requests, but you're right that FetchEvent is also necessary for incoming requests, and I think they're in the Service Worker spec (here), which is separate. So I guess a fix would be to mention FetchEvent in addition to the Fetch API, linking to the SW spec, if that sounds right to you.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully those browser APIs mirror each other and there is no surprise. Maybe linking both it the right thing to do.

There will be interesting details about streaming behavior of request and response. I know that not all browsers implement streaming in fetch. They buffer first until they have full body. Only Chromium knows how to stream.

And I don't know that is also true for service worker.

That said, maybe this WASI api could consider those details.

I guess other implementers may have similar limitations.

Also aborting, timeouts and canceling of promises is interesting in this context (in order to safe bandwidth and/or memory when you don't need the data anymore). Browsers implement those gradually ...

Sorry I have not looked at this WIT yet.

in a non-browser WebAssembly runtime and demonstrate embeddability in a
Web server.

[Fetch API]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

### Introduction

The WASI-http proposal defines a collection of [interfaces] for sending and
receiving HTTP requests and responses. WASI-http additionally defines a
[world], `wasi:http/proxy`, that circumscribes a minimal execution environment
for wasm HTTP [proxies].

[Interfaces]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-interfaces
[World]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds
[Proxies]: https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#intermediaries

### Goals

The proposal intends to abstract over HTTP version and transport protocol
choices (such as HTTP/1.1, HTTP/2 or HTTP/3) by mapping directly to the
abstract [HTTP Semantics], allowing hosts to (mostly) transparently use any of
these.

The `wasi:http/proxy` world is meant to be implementable by a wide variety of
hosts including Web [service workers], forward- and reverse-[proxies] and
[origin servers] by requiring a minimal set of additional runtime support.

The `wasi:http/proxy` world is meant to support flexible auto-scaling
("serverless") execution by moving the core `accept()` loop into the host and
allowing the host to dynamically spin up wasm instances in response to arriving
requests.

The `wasi:http/proxy` world is meant to allow the chaining of HTTP
intermediaries to be implemented directly in terms of [Component Model] linking.
(Fully realizing this goal will require additional features only available in
the [Preview 3] timeframe.)

[HTTP Semantics]: https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html
[Service Workers]: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
[Origin Servers]: https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#origin.server
[Component Model]: https://github.com/WebAssembly/component-model/
[Preview 3]: https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#streams

### Non-goals

WASI-http does not intend to define a more fully-featured cloud execution
environment (for this, see the [wasi-cloud-core] proposal).

[wasi-cloud-core]: https://github.com/WebAssembly/wasi-cloud-core

### API walk-through

The proposal can be understood by first reading the comments of [`proxy.wit`],
then [`handler.wit`] and finally [`types.wit`].

[`proxy.wit`]: ./wit/proxy.wit
[`handler.wit`]: ./wit/handler.wit
[`types.wit`]: ./wit/types.wit

### Working with the WIT

Bindings can be generated from the `wit` directory via:
```
wit-bindgen c wit/ --world proxy
```
or can be manipulated in other ways with:
and can be validated and otherwise manipulated via:
```
wasm-tools component wit wit/ ...
```
Expand All @@ -25,15 +96,8 @@ in the root directory, which fetches the live contents of the `main` branch of
each proposal. As things stablize, `wit/deps.toml` will be updated to refer to
versioned releases.

### Current Phase

wasi-http is currently in [Phase 1](https://github.com/WebAssembly/WASI/blob/main/Proposals.md).

### Champions

Piotr Sikora, Jiaxiao Zhou, Dan Chiarlone, David Justice
### References & acknowledgements

### TODO
* This proposal was seeded by and developed in consultation with
[proxy-wasm](https://github.com/proxy-wasm/spec).

This readme needs to be expanded to cover a number of additional fields suggested in the
[WASI Proposal template](https://github.com/WebAssembly/wasi-proposal-template).
19 changes: 19 additions & 0 deletions wit/incoming-handler.wit → wit/handler.wit
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ interface incoming-handler {
response-out: response-outparam
)
}

// The `wasi:http/outgoing-handler` interface is meant to be imported by
// components and implemented by the host.
//
// NOTE: in Preview3, this interface will be merged with
// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface
// that takes a `request` parameter and returns a `response` result.
//
interface outgoing-handler {
use types.{outgoing-request, request-options, future-incoming-response}

// The parameter and result types of the `handle` function allow the caller
// to concurrently stream the bodies of the outgoing request and the incoming
// response.
handle: func(
request: outgoing-request,
options: option<request-options>
) -> future-incoming-response
}
18 changes: 0 additions & 18 deletions wit/outgoing-handler.wit

This file was deleted.

Loading