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

Refactor feature/proc #94

Merged
merged 9 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all: capnp
clean: clean-capnp clean-mocks


capnp: capnp-anchor capnp-pubsub capnp-cluster capnp-channel capnp-proc capnp-iostream capnp-wasm
capnp: capnp-anchor capnp-pubsub capnp-cluster capnp-channel capnp-process capnp-iostream
# N.B.: compiling capnp schemas requires having capnproto.org/go/capnp/v3 installed
# on the GOPATH.

Expand All @@ -30,20 +30,16 @@ capnp-channel:
@mkdir -p internal/api/channel
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/std -ogo:internal/api/channel --src-prefix=api api/channel.capnp

capnp-proc:
@mkdir -p internal/api/proc
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/std -ogo:internal/api/proc --src-prefix=api api/proc.capnp
capnp-process:
@mkdir -p internal/api/process
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/std -ogo:internal/api/process --src-prefix=api api/process.capnp

capnp-iostream:
@mkdir -p internal/api/iostream
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/std -ogo:internal/api/iostream --src-prefix=api api/iostream.capnp

capnp-wasm:
@mkdir -p internal/api/wasm
@capnp compile -I$(GOPATH)/src/capnproto.org/go/capnp/std -ogo:internal/api/wasm --src-prefix=api api/wasm.capnp


clean-capnp: clean-capnp-anchor clean-capnp-pubsub clean-capnp-cluster clean-capnp-channel clean-capnp-proc clean-capnp-iostream clean-capnp-wasm
clean-capnp: clean-capnp-anchor clean-capnp-pubsub clean-capnp-cluster clean-capnp-channel clean-capnp-process clean-capnp-iostream clean-capnp-wasm

clean-capnp-anchor:
@rm -rf internal/api/anchor
Expand All @@ -57,15 +53,12 @@ clean-capnp-cluster:
clean-capnp-channel:
@rm -rf internal/api/channel

clean-capnp-proc:
@rm -rf internal/api/proc
clean-capnp-process:
@rm -rf internal/api/process

clean-capnp-iostream:
@rm -rf internal/api/iostream

clean-capnp-wasm:
@rm -rf internal/api/wasm


mocks: clean-mocks
# This roundabout call to 'go generate' allows us to:
Expand Down
27 changes: 14 additions & 13 deletions api/process.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ $Go.import("github.com/wetware/ww/internal/api/process");


interface Executor {
spawn @0 (binary :Data, entryfunction :Text) -> (process :Process);
spawn @0 (byteCode :Data, entryPoint :Text = "run") -> (process :Process);
# spawn a WASM based process from the binary module with the target
# entry function

using IOStream = import "iostream.capnp";
}

interface Process {
start @0 () -> (); # start the process
stop @1 () -> (); # TODO: provide a signal such as SIGTERM, SIGKILL...
wait @2 () -> (error :Text); # wait for an started process to finish
close @3 () -> (); # close should always be called after running a process

input @4 () -> (stdin :IOStream.Stream);
# the resulting stream can be used to provide input to the process
output @5(stdout :IOStream.Stream, stderr :IOStream.Stream) -> ();
# receives an stream to provide stdout and stderr to
start @0 () -> ();
stop @1 () -> ();
wait @2 () -> (error :Error);
}

using IOStream = import "iostream.capnp";
struct Error {
union {
none @0 :Void;
msg @1 :Text;
exitErr :group {
code @2 :UInt32;
module @3 :Text;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does module represent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, this is the name of the module. It is one of the fields contained in sys.ExitError, which is returned by calls to exported module functions. (Maybe we should rename to moduleName?)

}
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ require (
github.com/lthibault/go-libp2p-inproc-transport v0.4.0
github.com/multiformats/go-multistream v0.4.1
github.com/stretchr/testify v1.8.1
github.com/tetratelabs/wazero v1.0.0-pre.4
github.com/tetratelabs/wazero v1.0.0-rc.1
github.com/thejerf/suture/v4 v4.0.2
github.com/wetware/casm v0.0.0-20230224203443-f715090fc92c
golang.org/x/sync v0.1.0
gopkg.in/alexcesaro/statsd.v2 v2.0.0
lukechampine.com/blake3 v1.1.7
)

require (
Expand Down Expand Up @@ -150,6 +151,5 @@ require (
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tetratelabs/wazero v1.0.0-pre.4 h1:RBJQT5OzmORkSp6MmZDWoFEr0zXjk4pmvMKAdeUnsaI=
github.com/tetratelabs/wazero v1.0.0-pre.4/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
github.com/tetratelabs/wazero v1.0.0-rc.1 h1:ytecMV5Ue0BwezjKh/cM5yv1Mo49ep2R2snSsQUyToc=
github.com/tetratelabs/wazero v1.0.0-rc.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
github.com/thejerf/suture/v4 v4.0.2 h1:VxIH/J8uYvqJY1+9fxi5GBfGRkRZ/jlSOP6x9HijFQc=
github.com/thejerf/suture/v4 v4.0.2/go.mod h1:g0e8vwskm9tI0jRjxrnA6lSr0q6OfPdWJVX7G5bVWRs=
github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0=
Expand Down
98 changes: 49 additions & 49 deletions internal/api/cluster/cluster.capnp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading