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

Restore and improve cluster run command #149

Merged
merged 26 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f2c8fb5
Keep track of process hierarchy with a process tree
mikelsr Aug 11, 2023
b1840ef
Keep track of process hierarchy with a process tree
mikelsr Aug 11, 2023
810ecde
Keep track of process hierarchy with a process tree
mikelsr Aug 11, 2023
0c90dd2
Partially restore command
mikelsr Aug 11, 2023
5b0c814
Retrieve a host before running cluster commands
mikelsr Aug 11, 2023
ad612ee
Cleanup.
lthibault Aug 11, 2023
a11cb94
Add logging for rpc.Conn.
lthibault Aug 11, 2023
e87ffa4
Cleanup.
lthibault Aug 11, 2023
f66eaab
Expect host.Host as bootstrap client.
lthibault Aug 11, 2023
4df6299
Rebase v0.1.0
mikelsr Aug 12, 2023
d61d44a
Code cleanup & logging improvements.
lthibault Aug 11, 2023
5600fa4
Move subcommands from internal/cmd to cmd/ww.
lthibault Aug 11, 2023
1da0703
Cleanup.
lthibault Aug 11, 2023
20abf65
Add logging for rpc.Conn.
lthibault Aug 11, 2023
331e488
Cleanup.
lthibault Aug 11, 2023
9b0b151
Expect host.Host as bootstrap client.
lthibault Aug 11, 2023
e3768ab
Rebase v0.1.0
mikelsr Aug 12, 2023
13063c4
Code cleanup & logging improvements.
lthibault Aug 11, 2023
31a8983
Rebase proctree
mikelsr Aug 12, 2023
e102cd2
Merge remote-tracking branch 'origin/bytecode_cache' into proctree
mikelsr Aug 12, 2023
ad576bc
Solve merge conflicts
mikelsr Aug 12, 2023
68d33e9
Merge branch 'bytecode_cache' into proctree
mikelsr Aug 12, 2023
3c1f940
Resolve merge conflicts
mikelsr Aug 12, 2023
fec1c40
Release conn and host in teardown
mikelsr Aug 12, 2023
a966d9a
Solve merge conflicts
mikelsr Aug 13, 2023
8efed43
Merge branch 'proctree' into cluster_run
mikelsr Aug 13, 2023
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
4 changes: 2 additions & 2 deletions api/process.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ $Go.import("github.com/wetware/pkg/api/process");
interface Executor {
# Executor has the ability to create and run WASM processes given the
# WASM bytecode.
exec @0 (bytecode :Data, bootstrapClient :Capability) -> (process :Process);
exec @0 (bytecode :Data, ppid :UInt32, bootstrapClient :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 bootContext.
#
# The Process capability is associated to the created process.
execCached @1 (cid :Text, bootstrapClient :Capability) -> (process :Process);
execCached @1 (cid :Text, ppid :UInt32, bootstrapClient :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
150 changes: 84 additions & 66 deletions api/process/process.capnp.go

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

32 changes: 28 additions & 4 deletions cap/csp/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,33 @@ func (ex Executor) Release() {
capnp.Client(ex).Release()
}

func (ex Executor) Exec(ctx context.Context, src []byte) (Proc, capnp.ReleaseFunc) {
f, release := api.Executor(ex).Exec(ctx, func(ps api.Executor_exec_Params) error {
return ps.SetBytecode(src)
})
// Exec spawns a new process from WASM bytecode bc. If the caller is a WASM process
// spawned in this same executor, it should use its PID as ppid to mark the
// new process as a subprocess.
func (ex Executor) Exec(ctx context.Context, bc []byte, ppid uint32, client capnp.Client) (Proc, capnp.ReleaseFunc) {
f, release := api.Executor(ex).Exec(ctx,
func(ps api.Executor_exec_Params) error {
if err := ps.SetBytecode(bc); err != nil {
return err
}

ps.SetPpid(ppid)
return ps.SetBootstrapClient(client)
})
return Proc(f.Process()), release
}

// ExecFromCache behaves the same way as Exec, but expects the bytecode to be already
// cached at the executor.
func (ex Executor) ExecFromCache(ctx context.Context, cid string, ppid uint32, client capnp.Client) (Proc, capnp.ReleaseFunc) {
f, release := api.Executor(ex).ExecCached(ctx,
func(ps api.Executor_execCached_Params) error {
if err := ps.SetCid(cid); err != nil {
return err
}

ps.SetPpid(ppid)
return ps.SetBootstrapClient(client)
})
return Proc(f.Process()), release
}
24 changes: 19 additions & 5 deletions cap/csp/proc.go → cap/csp/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,26 @@ func (p Proc) Release() {
capnp.Client(p).Release()
}

// func (p Proc) Kill(ctx context.Context) error {
// f, release := api.Process(p).Kill(ctx, nil)
// defer release()
// Kill a process and any sub processes it might have spawned.
func (p Proc) Kill(ctx context.Context) error {
f, release := api.Process(p).Kill(ctx, nil)
defer release()

select {
case <-f.Done():
case <-ctx.Done():
}

if ctx.Err() != nil {
return ctx.Err()
}

// return casm.Future(f).Await(ctx)
// }
_, err := f.Struct()
if err != nil {
return err
}
return nil
}

func (p Proc) Wait(ctx context.Context) error {
f, release := api.Process(p).Wait(ctx, nil)
Expand Down
Loading