Skip to content

Commit

Permalink
Semi-finish exec call signature implementation #133
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelsr committed Jul 28, 2023
1 parent fd5caa9 commit 81f01e4
Show file tree
Hide file tree
Showing 13 changed files with 421 additions and 220 deletions.
4 changes: 2 additions & 2 deletions api/process.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ using Tools = import "/experiments/tools.capnp";
interface Executor {
# Executor has the ability to create and run WASM processes given the
# WASM bytecode.
exec @0 (bytecode :Data, caps :List(Capability)) -> (process :Process);
exec @0 (bytecode :Data, spid :Data, caps :List(Capability)) -> (process :Process);
# Exec creates an runs a process from the provided bytecode. Optionally, a
# capability can be passed through the `cap` parameter. This capability will
# be available at the process inbox.
#
# The Process capability is associated to the created process.
execFromCache @1 (md5sum :Data, caps :List(Capability)) -> (process :Process);
execFromCache @1 (md5sum :Data, spid :Data, caps :List(Capability)) -> (process :Process);
# Same as Exec, but the bytecode is directly from the BytecodeRegistry.
# Provides a significant performance improvement for medium to large
# WASM streams.
Expand Down
227 changes: 127 additions & 100 deletions api/process/process.capnp.go

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

14 changes: 12 additions & 2 deletions pkg/csp/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ func (ex Executor) Release() {
capnp.Client(ex).Release()
}

func (ex Executor) Exec(ctx context.Context, src []byte, caps ...capnp.Client) (Proc, capnp.ReleaseFunc) {
func (ex Executor) Exec(ctx context.Context, src []byte, spid []byte, caps ...capnp.Client) (Proc, capnp.ReleaseFunc) {
f, release := api.Executor(ex).Exec(ctx, func(ps api.Executor_exec_Params) error {
if err := ps.SetBytecode(src); err != nil {
return err
}
if spid != nil {
if err := ps.SetSpid(spid); err != nil {
return err
}
}
if caps == nil {
return nil
}
Expand All @@ -37,11 +42,16 @@ func (ex Executor) Exec(ctx context.Context, src []byte, caps ...capnp.Client) (
return Proc(f.Process()), release
}

func (ex Executor) ExecFromCache(ctx context.Context, md5sum []byte, caps ...capnp.Client) (Proc, capnp.ReleaseFunc) {
func (ex Executor) ExecFromCache(ctx context.Context, md5sum []byte, spid []byte, caps ...capnp.Client) (Proc, capnp.ReleaseFunc) {
f, release := api.Executor(ex).ExecFromCache(ctx, func(ps api.Executor_execFromCache_Params) error {
if err := ps.SetMd5sum(md5sum); err != nil {
return err
}
if spid != nil {
if err := ps.SetSpid(spid); err != nil {
return err
}
}
if caps == nil {
return nil
}
Expand Down
Loading

0 comments on commit 81f01e4

Please sign in to comment.