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

feat: add Wagi HTTP executor #54

Merged
merged 1 commit into from
Feb 14, 2022
Merged

feat: add Wagi HTTP executor #54

merged 1 commit into from
Feb 14, 2022

Conversation

radu-matei
Copy link
Member

@radu-matei radu-matei commented Feb 8, 2022

ref #34

This draft PR is a prototype for running both Spin and Wagi HTTP executors.
It adapts the response composition logic from Wagi, and reuses the module instantiation from the underlying execution context.

A robust implementation would import the Wagi core as a crate and reuse the logic for headers, query parameters, and responses.

This should remain a draft until this implementation follows the Wagi spec closely.

WIth this change, a component of an HTTP application could define wagi as its executor:

name        = "spin-hello-world"
version     = "1.0.0"
description = "A simple application that returns hello and goodbye."
authors     = [ "Radu Matei <radu@fermyon.com>" ]
trigger     = "http"

[[component]]
    source = "target/wasm32-wasi/release/spinhelloworld.wasm"
    id     = "hello"
[component.trigger]
    route    = "/hello"
    executor = "spin"

[[component]]
    source = "wagi.wasm"
    id     = "wagi"
[component.trigger]
    route    = "/wagi"
    executor = "wagi"

Signed-off-by: Radu Matei radu.matei@fermyon.com

@radu-matei radu-matei linked an issue Feb 8, 2022 that may be closed by this pull request
@radu-matei
Copy link
Member Author

The one Wagi feature that will most likely not be part of this is a module defining its own routes using a _routes() function.

Because an executor doesn't have access to the underlying Wasm engine instantiation, there is no way for it to do that at startup and augment the route table (ref #19 ).

/// This is the default Wagi entrypoint.
/// There should be a way to set this in the component
/// configuration of the trigger / executor.
const WAGI_DEFAULT_ENTRYPOINT: &str = "_start";
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: allow custom entrypoints in the component configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #69 to track this.

@radu-matei radu-matei marked this pull request as ready for review February 11, 2022 06:11
This commit implements a Wagi HTTP executor by importing the Wagi project
in order to:

    * parse the headers from a Hyper request into CGI headers
    * consume the standard output of the module to form the response

This allows a Spin application to have components that are executed
by Wagi, which enables writing modules from all languages that compile
to WASI.

Signed-off-by: Radu Matei <radu.matei@fermyon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discussion]: Implement Wagi HTTP executor
2 participants