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

Investigate breaking off wasi:io from spin-test-virt #103

Open
rylev opened this issue Jun 27, 2024 · 0 comments
Open

Investigate breaking off wasi:io from spin-test-virt #103

rylev opened this issue Jun 27, 2024 · 0 comments

Comments

@rylev
Copy link
Collaborator

rylev commented Jun 27, 2024

It would be nice if we could break up spin-test-virt into several different components which could be swapped out or reused by other projects. One of the most central pieces of spin-test-virt is wasi:io which powers a lot of different interfaces in wasi (e.g., wasi:filesystem and wasi:http).

The approach one would imagine to take would be to create a component with the following wit:

package fermyon:wasi-io-virt;

/// Configurable virtualized implementation of `wasi:io`.
world io {
    export wasi:io/streams@0.2.0;
    export wasi:io/error@0.2.0;
    export wasi:io/poll@0.2.0;
    
    import wasi:io/streams@0.2.0;
    import wasi:io/error@0.2.0;
    import wasi:io/poll@0.2.0;

    export config;
}

interface config {
    use wasi:io/poll@0.2.0.{pollable};
    
    /// Create a new pollable.
    new-poll: func(config: pollable-config) -> pollable;

    variant pollable-config {
        /// The pollable comes from the host.
        host(pollable),
        /// The pollable is virtualized.
        virtualized
    }

    // Imagine similar interfaces for `input-stream` and `output-stream`
}

This component both imports and exports wasi:io as well as an additional config interface. The component can virtualize all io interfaces in terms of the imported interfaces (either be implementing them within the component or by delegating to the imported interfaces. The config interface allows users of the component to create new io resources that are either virtualized or backed by some imported resource.

This, however, won't work as imagined as the pollable used in config refers to the exported pollable resource where we would need for it to refer to the imported pollable resource. Unfortunately WIT doesn't allow you to refer to imported items in an exported interface. While this is possible in the component model, it is not possible in WIT today.

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

No branches or pull requests

1 participant