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

Add host module for ww proc API. #111

Closed
wants to merge 3 commits into from
Closed

Conversation

lthibault
Copy link
Collaborator

@lthibault lthibault commented Apr 15, 2023

Stacked on top of #109 & #110. Merge those first ✔️

The scope of this PR has expanded a little bit since I started, so I'm cutting it off here. At present, it adds:

  1. pkg/csp/proc: a WASM host module that provides a Cap'n Proto RPC transport between the host and guest code.
  2. guest/tinygo: a library for writing processes written in Go using TinyGo

Follow-up work:

  • Pass a Host capability (or equivalent) to pkg/csp/proc.Module (currently, the guest sees a null capability)
  • Define and implement top-level guest API in guest/tinygo
  • Unit tests, benchmarks & performance tuning
  • Mechanism to limit which capabilities are passed into a process
  • Guest libraries for other languages (maybe we should do JS next?)

What is a host module?

A host module is native Go code that the webassembly binary can call. It's webassembly module whose functions are implemented by Wetware itself.

What is guest/tinygo?

guest/tinygo is a client library for users who wish to write Wetware processes in Go, using TinyGo. When imported, it will provide access to cluster capabilities like pubsub, processes, etc. It is not yet fully implemented, but it does succeed in negotiating an rpc.Conn with the host.

Users are able to write processes as ordinary Go programs, e.g.:

package main

import (
    "fmt"


    ww "github.com/wetware/ww/guest/tinygo
)

func main() {
    // get the root anchor; this functionality is WIP.
    it, release := ww.Root().Ls(context.Background())  
    defer release()

    for name := it.Next(); name != ""; name = it.Next() {
         fmt.Println(name)  // This works, though!  Feel free to try hello world!
    }
}

To compile: tinygo -o main.wasm -scheduler=asyncify -target=wasi main.go
To run: ww run main.wasi

@lthibault lthibault added the enhancement New feature or request label Apr 15, 2023
@lthibault lthibault requested a review from mikelsr April 15, 2023 20:36
@lthibault lthibault self-assigned this Apr 15, 2023
@lthibault lthibault force-pushed the feat/proc-exports branch 2 times, most recently from c941423 to 3749f5e Compare April 15, 2023 20:45
Copy link
Contributor

@mikelsr mikelsr left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for taking the time to do it and talk it with me!

@lthibault lthibault marked this pull request as ready for review April 18, 2023 18:38
@lthibault lthibault requested a review from mikelsr April 18, 2023 18:38
@lthibault lthibault marked this pull request as draft April 18, 2023 18:40
@lthibault
Copy link
Collaborator Author

Converting to draft. I'm going to try to break this into a few smaller PRs.

This was referenced Apr 18, 2023
lthibault referenced this pull request Apr 18, 2023
https://github.com/wetware/ww/pull/111 requires unsafe.SliceData,
which is not available before 1.20.  This PR updates the version
number in go.mod and removes 1.19 from CI.

We could preserve backwards compatibility by using build tags and
relying on the highly-unsafe runtime.SliceHeader, but given that
we are still pre-1.0, I don't think it's worth the trouble.
lthibault referenced this pull request Apr 19, 2023
https://github.com/wetware/ww/pull/111 requires unsafe.SliceData,
which is not available before 1.20.  This PR updates the version
number in go.mod and removes 1.19 from CI.

We could preserve backwards compatibility by using build tags and
relying on the highly-unsafe runtime.SliceHeader, but given that
we are still pre-1.0, I don't think it's worth the trouble.
@lthibault lthibault mentioned this pull request Apr 27, 2023
@lthibault
Copy link
Collaborator Author

I think this has been superseded. Closing, but happy to reopen if needed.

@lthibault lthibault closed this Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants