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

Added wasi for v1 wasmrs components & helper macros. #384

Merged
merged 5 commits into from
Jul 27, 2023
Merged

Added wasi for v1 wasmrs components & helper macros. #384

merged 5 commits into from
Jul 27, 2023

Conversation

jsoverson
Copy link
Contributor

This PR adds WASI support for v1 wasmrs components.

Sample config:

name: 'wasi-fs'
kind: wick/component@v1
metadata:
  version: '0.0.1'
resources:
  - name: ROOT
    resource:
      kind: wick/resource/volume@v1
      path: '{{ctx.root_config.root}}'
component:
  kind: wick/component/wasmrs@v1
  ref: build/component.signed.wasm
  volumes:
    - resource: ROOT
      path: /
  with:
    - name: root
      type: string
  operations:
    - name: read_string
      inputs:
        - name: filename
          type: string
      outputs:
        - name: output
          type: string
    - name: write_string
      inputs:
        - name: filename
          type: string
        - name: contents
          type: string
      outputs:
        - name: bytes_written
          type: int

As part of building the WASI test modules, I included experimental macros and proc_macro attributes for common operation cases. The WASI module showcases them but they're not necessary to rely on or use.

Breaking changes for component devs:

  • There was an inconsistency to the naming patterns in wick-component-codegen. Everything generated for operations was housed under individual operation_name::* modules in the generated code, except the operation trait itself which was named [OperationName]Operation. This PR moves the operation trait to operation_name::Operation. To recompile old components, the operation implementations need to be changed from impl OperationNameOperation for Component to impl operation_name::Operation for Component.
  • The .error() method on outputs now takes a &str instead of impl AsRef<str> due to becoming a trait methods vs generated code. Any call to .error that passed in a String or otherwise will need to be updated to pass a string slice instead (e.g. outputs.output.error(an_error_string) needs to be changed to outputs.output.error(&an_error_string)

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.

2 participants