-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement the 2023_10_18 version of web serving. #95
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,10 @@ import ( | |
"github.com/tetratelabs/wazero" | ||
) | ||
|
||
const ModuleName = "streams" | ||
const ( | ||
ModuleName = "streams" | ||
ModuleName_2023_10_18 = "wasi:io/streams@0.2.0-rc-2023-10-18" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have been trying to get this PR working with https://github.com/dev-wasm/dev-wasm-go/tree/main/http without success. The first issue is that module name should be
perhaps some mismatch between versions in dev-wasm-go and wasi-go There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just thinking, could it make sense to make one working combination with wasi-go wasi_http and dev-wasm-go client? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zetaab https://github.com/brendandburns/hello-wasi-http-go I'll try to get |
||
) | ||
|
||
type Stream struct { | ||
reader io.Reader | ||
|
@@ -30,11 +33,21 @@ func MakeStreams() *Streams { | |
} | ||
} | ||
|
||
func Instantiate(ctx context.Context, r wazero.Runtime, s *Streams) error { | ||
func Instantiate_v1(ctx context.Context, r wazero.Runtime, s *Streams) error { | ||
_, err := r.NewHostModuleBuilder(ModuleName). | ||
NewFunctionBuilder().WithFunc(s.streamReadFn).Export("read"). | ||
NewFunctionBuilder().WithFunc(s.dropInputStreamFn).Export("drop-input-stream"). | ||
NewFunctionBuilder().WithFunc(s.writeStreamFn).Export("write"). | ||
NewFunctionBuilder().WithFunc(s.blockingWriteAndFlush).Export("write"). | ||
Instantiate(ctx) | ||
return err | ||
} | ||
|
||
func Instantiate_2023_10_18(ctx context.Context, r wazero.Runtime, s *Streams) error { | ||
_, err := r.NewHostModuleBuilder(ModuleName_2023_10_18). | ||
NewFunctionBuilder().WithFunc(s.streamReadFn).Export("[method]input-stream.read"). | ||
NewFunctionBuilder().WithFunc(s.dropInputStreamFn).Export("[resource-drop]input-stream"). | ||
NewFunctionBuilder().WithFunc(s.blockingWriteAndFlush).Export("[method]output-stream.blocking-write-and-flush"). | ||
//NewFunctionBuilder().WithFunc(s.writeStreamFn).Export("write"). | ||
Instantiate(ctx) | ||
return err | ||
} | ||
|
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.
Is this condition expected to ever happen? Or would it be better suited to panic if we hit it?
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 condition will happen if someone loads a WASM binary that doesn't export the right function.
In such a situation, it feels like the right thing to do is have the server return a 500 error, as opposed to crashing via
panic()