diff --git a/api/process.capnp b/api/process.capnp index 518e6a63..15e95cf4 100644 --- a/api/process.capnp +++ b/api/process.capnp @@ -7,13 +7,11 @@ $Go.import("github.com/wetware/ww/internal/api/process"); interface Executor { - spawn @0 (byteCode :Data, entryPoint :Text = "run") -> (process :Process); - # spawn a WASM based process from the binary module with the target - # entry function + exec @0 (bytecode :Data) -> (process :Process); + # exec a WASM based process } interface Process { - start @0 () -> (); - stop @1 () -> (); - wait @2 () -> (exitCode :UInt32); + wait @0 () -> (exitCode :UInt32); + kill @1 () -> (); } diff --git a/internal/api/process/process.capnp.go b/internal/api/process/process.capnp.go index f06d2d63..55a78f39 100644 --- a/internal/api/process/process.capnp.go +++ b/internal/api/process/process.capnp.go @@ -16,23 +16,23 @@ type Executor capnp.Client // Executor_TypeID is the unique identifier for the type Executor. const Executor_TypeID = 0xaf2e5ebaa58175d2 -func (c Executor) Spawn(ctx context.Context, params func(Executor_spawn_Params) error) (Executor_spawn_Results_Future, capnp.ReleaseFunc) { +func (c Executor) Exec(ctx context.Context, params func(Executor_exec_Params) error) (Executor_exec_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xaf2e5ebaa58175d2, MethodID: 0, InterfaceName: "process.capnp:Executor", - MethodName: "spawn", + MethodName: "exec", }, } if params != nil { - s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 2} - s.PlaceArgs = func(s capnp.Struct) error { return params(Executor_spawn_Params(s)) } + s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 1} + s.PlaceArgs = func(s capnp.Struct) error { return params(Executor_exec_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Executor_spawn_Results_Future{Future: ans.Future()}, release + return Executor_exec_Results_Future{Future: ans.Future()}, release } @@ -109,7 +109,7 @@ func (c Executor) GetFlowLimiter() fc.FlowLimiter { // A Executor_Server is a Executor with a local implementation. type Executor_Server interface { - Spawn(context.Context, Executor_spawn) error + Exec(context.Context, Executor_exec) error } // Executor_NewServer creates a new Server from an implementation of Executor_Server. @@ -136,31 +136,31 @@ func Executor_Methods(methods []server.Method, s Executor_Server) []server.Metho InterfaceID: 0xaf2e5ebaa58175d2, MethodID: 0, InterfaceName: "process.capnp:Executor", - MethodName: "spawn", + MethodName: "exec", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Spawn(ctx, Executor_spawn{call}) + return s.Exec(ctx, Executor_exec{call}) }, }) return methods } -// Executor_spawn holds the state for a server call to Executor.spawn. +// Executor_exec holds the state for a server call to Executor.exec. // See server.Call for documentation. -type Executor_spawn struct { +type Executor_exec struct { *server.Call } // Args returns the call's arguments. -func (c Executor_spawn) Args() Executor_spawn_Params { - return Executor_spawn_Params(c.Call.Args()) +func (c Executor_exec) Args() Executor_exec_Params { + return Executor_exec_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Executor_spawn) AllocResults() (Executor_spawn_Results, error) { +func (c Executor_exec) AllocResults() (Executor_exec_Results, error) { r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(r), err + return Executor_exec_Results(r), err } // Executor_List is a list of Executor. @@ -172,158 +172,140 @@ func NewExecutor_List(s *capnp.Segment, sz int32) (Executor_List, error) { return capnp.CapList[Executor](l), err } -type Executor_spawn_Params capnp.Struct +type Executor_exec_Params capnp.Struct -// Executor_spawn_Params_TypeID is the unique identifier for the type Executor_spawn_Params. -const Executor_spawn_Params_TypeID = 0xf20b3dea95929312 +// Executor_exec_Params_TypeID is the unique identifier for the type Executor_exec_Params. +const Executor_exec_Params_TypeID = 0xf20b3dea95929312 -func NewExecutor_spawn_Params(s *capnp.Segment) (Executor_spawn_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Executor_spawn_Params(st), err +func NewExecutor_exec_Params(s *capnp.Segment) (Executor_exec_Params, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return Executor_exec_Params(st), err } -func NewRootExecutor_spawn_Params(s *capnp.Segment) (Executor_spawn_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Executor_spawn_Params(st), err +func NewRootExecutor_exec_Params(s *capnp.Segment) (Executor_exec_Params, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return Executor_exec_Params(st), err } -func ReadRootExecutor_spawn_Params(msg *capnp.Message) (Executor_spawn_Params, error) { +func ReadRootExecutor_exec_Params(msg *capnp.Message) (Executor_exec_Params, error) { root, err := msg.Root() - return Executor_spawn_Params(root.Struct()), err + return Executor_exec_Params(root.Struct()), err } -func (s Executor_spawn_Params) String() string { +func (s Executor_exec_Params) String() string { str, _ := text.Marshal(0xf20b3dea95929312, capnp.Struct(s)) return str } -func (s Executor_spawn_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Executor_exec_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Executor_spawn_Params) DecodeFromPtr(p capnp.Ptr) Executor_spawn_Params { - return Executor_spawn_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Executor_exec_Params) DecodeFromPtr(p capnp.Ptr) Executor_exec_Params { + return Executor_exec_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Executor_spawn_Params) ToPtr() capnp.Ptr { +func (s Executor_exec_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Executor_spawn_Params) IsValid() bool { +func (s Executor_exec_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Executor_spawn_Params) Message() *capnp.Message { +func (s Executor_exec_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Executor_spawn_Params) Segment() *capnp.Segment { +func (s Executor_exec_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -func (s Executor_spawn_Params) ByteCode() ([]byte, error) { +func (s Executor_exec_Params) Bytecode() ([]byte, error) { p, err := capnp.Struct(s).Ptr(0) return []byte(p.Data()), err } -func (s Executor_spawn_Params) HasByteCode() bool { +func (s Executor_exec_Params) HasBytecode() bool { return capnp.Struct(s).HasPtr(0) } -func (s Executor_spawn_Params) SetByteCode(v []byte) error { +func (s Executor_exec_Params) SetBytecode(v []byte) error { return capnp.Struct(s).SetData(0, v) } -func (s Executor_spawn_Params) EntryPoint() (string, error) { - p, err := capnp.Struct(s).Ptr(1) - return p.TextDefault("run"), err -} - -func (s Executor_spawn_Params) HasEntryPoint() bool { - return capnp.Struct(s).HasPtr(1) -} - -func (s Executor_spawn_Params) EntryPointBytes() ([]byte, error) { - p, err := capnp.Struct(s).Ptr(1) - return p.TextBytesDefault("run"), err -} - -func (s Executor_spawn_Params) SetEntryPoint(v string) error { - return capnp.Struct(s).SetNewText(1, v) -} +// Executor_exec_Params_List is a list of Executor_exec_Params. +type Executor_exec_Params_List = capnp.StructList[Executor_exec_Params] -// Executor_spawn_Params_List is a list of Executor_spawn_Params. -type Executor_spawn_Params_List = capnp.StructList[Executor_spawn_Params] - -// NewExecutor_spawn_Params creates a new list of Executor_spawn_Params. -func NewExecutor_spawn_Params_List(s *capnp.Segment, sz int32) (Executor_spawn_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) - return capnp.StructList[Executor_spawn_Params](l), err +// NewExecutor_exec_Params creates a new list of Executor_exec_Params. +func NewExecutor_exec_Params_List(s *capnp.Segment, sz int32) (Executor_exec_Params_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) + return capnp.StructList[Executor_exec_Params](l), err } -// Executor_spawn_Params_Future is a wrapper for a Executor_spawn_Params promised by a client call. -type Executor_spawn_Params_Future struct{ *capnp.Future } +// Executor_exec_Params_Future is a wrapper for a Executor_exec_Params promised by a client call. +type Executor_exec_Params_Future struct{ *capnp.Future } -func (f Executor_spawn_Params_Future) Struct() (Executor_spawn_Params, error) { +func (f Executor_exec_Params_Future) Struct() (Executor_exec_Params, error) { p, err := f.Future.Ptr() - return Executor_spawn_Params(p.Struct()), err + return Executor_exec_Params(p.Struct()), err } -type Executor_spawn_Results capnp.Struct +type Executor_exec_Results capnp.Struct -// Executor_spawn_Results_TypeID is the unique identifier for the type Executor_spawn_Results. -const Executor_spawn_Results_TypeID = 0xbb4f16b0a7d2d09b +// Executor_exec_Results_TypeID is the unique identifier for the type Executor_exec_Results. +const Executor_exec_Results_TypeID = 0xbb4f16b0a7d2d09b -func NewExecutor_spawn_Results(s *capnp.Segment) (Executor_spawn_Results, error) { +func NewExecutor_exec_Results(s *capnp.Segment) (Executor_exec_Results, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(st), err + return Executor_exec_Results(st), err } -func NewRootExecutor_spawn_Results(s *capnp.Segment) (Executor_spawn_Results, error) { +func NewRootExecutor_exec_Results(s *capnp.Segment) (Executor_exec_Results, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(st), err + return Executor_exec_Results(st), err } -func ReadRootExecutor_spawn_Results(msg *capnp.Message) (Executor_spawn_Results, error) { +func ReadRootExecutor_exec_Results(msg *capnp.Message) (Executor_exec_Results, error) { root, err := msg.Root() - return Executor_spawn_Results(root.Struct()), err + return Executor_exec_Results(root.Struct()), err } -func (s Executor_spawn_Results) String() string { +func (s Executor_exec_Results) String() string { str, _ := text.Marshal(0xbb4f16b0a7d2d09b, capnp.Struct(s)) return str } -func (s Executor_spawn_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Executor_exec_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Executor_spawn_Results) DecodeFromPtr(p capnp.Ptr) Executor_spawn_Results { - return Executor_spawn_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Executor_exec_Results) DecodeFromPtr(p capnp.Ptr) Executor_exec_Results { + return Executor_exec_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Executor_spawn_Results) ToPtr() capnp.Ptr { +func (s Executor_exec_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Executor_spawn_Results) IsValid() bool { +func (s Executor_exec_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Executor_spawn_Results) Message() *capnp.Message { +func (s Executor_exec_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Executor_spawn_Results) Segment() *capnp.Segment { +func (s Executor_exec_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -func (s Executor_spawn_Results) Process() Process { +func (s Executor_exec_Results) Process() Process { p, _ := capnp.Struct(s).Ptr(0) return Process(p.Interface().Client()) } -func (s Executor_spawn_Results) HasProcess() bool { +func (s Executor_exec_Results) HasProcess() bool { return capnp.Struct(s).HasPtr(0) } -func (s Executor_spawn_Results) SetProcess(v Process) error { +func (s Executor_exec_Results) SetProcess(v Process) error { if !v.IsValid() { return capnp.Struct(s).SetPtr(0, capnp.Ptr{}) } @@ -332,23 +314,23 @@ func (s Executor_spawn_Results) SetProcess(v Process) error { return capnp.Struct(s).SetPtr(0, in.ToPtr()) } -// Executor_spawn_Results_List is a list of Executor_spawn_Results. -type Executor_spawn_Results_List = capnp.StructList[Executor_spawn_Results] +// Executor_exec_Results_List is a list of Executor_exec_Results. +type Executor_exec_Results_List = capnp.StructList[Executor_exec_Results] -// NewExecutor_spawn_Results creates a new list of Executor_spawn_Results. -func NewExecutor_spawn_Results_List(s *capnp.Segment, sz int32) (Executor_spawn_Results_List, error) { +// NewExecutor_exec_Results creates a new list of Executor_exec_Results. +func NewExecutor_exec_Results_List(s *capnp.Segment, sz int32) (Executor_exec_Results_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) - return capnp.StructList[Executor_spawn_Results](l), err + return capnp.StructList[Executor_exec_Results](l), err } -// Executor_spawn_Results_Future is a wrapper for a Executor_spawn_Results promised by a client call. -type Executor_spawn_Results_Future struct{ *capnp.Future } +// Executor_exec_Results_Future is a wrapper for a Executor_exec_Results promised by a client call. +type Executor_exec_Results_Future struct{ *capnp.Future } -func (f Executor_spawn_Results_Future) Struct() (Executor_spawn_Results, error) { +func (f Executor_exec_Results_Future) Struct() (Executor_exec_Results, error) { p, err := f.Future.Ptr() - return Executor_spawn_Results(p.Struct()), err + return Executor_exec_Results(p.Struct()), err } -func (p Executor_spawn_Results_Future) Process() Process { +func (p Executor_exec_Results_Future) Process() Process { return Process(p.Future.Field(0, nil).Client()) } @@ -357,63 +339,43 @@ type Process capnp.Client // Process_TypeID is the unique identifier for the type Process. const Process_TypeID = 0xda23f0d3a8250633 -func (c Process) Start(ctx context.Context, params func(Process_start_Params) error) (Process_start_Results_Future, capnp.ReleaseFunc) { +func (c Process) Wait(ctx context.Context, params func(Process_wait_Params) error) (Process_wait_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xda23f0d3a8250633, MethodID: 0, InterfaceName: "process.capnp:Process", - MethodName: "start", + MethodName: "wait", }, } if params != nil { s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_start_Params(s)) } + s.PlaceArgs = func(s capnp.Struct) error { return params(Process_wait_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_start_Results_Future{Future: ans.Future()}, release + return Process_wait_Results_Future{Future: ans.Future()}, release } -func (c Process) Stop(ctx context.Context, params func(Process_stop_Params) error) (Process_stop_Results_Future, capnp.ReleaseFunc) { +func (c Process) Kill(ctx context.Context, params func(Process_kill_Params) error) (Process_kill_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xda23f0d3a8250633, MethodID: 1, InterfaceName: "process.capnp:Process", - MethodName: "stop", - }, - } - if params != nil { - s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_stop_Params(s)) } - } - - ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_stop_Results_Future{Future: ans.Future()}, release - -} - -func (c Process) Wait(ctx context.Context, params func(Process_wait_Params) error) (Process_wait_Results_Future, capnp.ReleaseFunc) { - - s := capnp.Send{ - Method: capnp.Method{ - InterfaceID: 0xda23f0d3a8250633, - MethodID: 2, - InterfaceName: "process.capnp:Process", - MethodName: "wait", + MethodName: "kill", }, } if params != nil { s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_wait_Params(s)) } + s.PlaceArgs = func(s capnp.Struct) error { return params(Process_kill_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_wait_Results_Future{Future: ans.Future()}, release + return Process_kill_Results_Future{Future: ans.Future()}, release } @@ -490,11 +452,9 @@ func (c Process) GetFlowLimiter() fc.FlowLimiter { // A Process_Server is a Process with a local implementation. type Process_Server interface { - Start(context.Context, Process_start) error - - Stop(context.Context, Process_stop) error - Wait(context.Context, Process_wait) error + + Kill(context.Context, Process_kill) error } // Process_NewServer creates a new Server from an implementation of Process_Server. @@ -513,7 +473,7 @@ func Process_ServerToClient(s Process_Server) Process { // This can be used to create a more complicated Server. func Process_Methods(methods []server.Method, s Process_Server) []server.Method { if cap(methods) == 0 { - methods = make([]server.Method, 0, 3) + methods = make([]server.Method, 0, 2) } methods = append(methods, server.Method{ @@ -521,10 +481,10 @@ func Process_Methods(methods []server.Method, s Process_Server) []server.Method InterfaceID: 0xda23f0d3a8250633, MethodID: 0, InterfaceName: "process.capnp:Process", - MethodName: "start", + MethodName: "wait", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Start(ctx, Process_start{call}) + return s.Wait(ctx, Process_wait{call}) }, }) @@ -533,77 +493,48 @@ func Process_Methods(methods []server.Method, s Process_Server) []server.Method InterfaceID: 0xda23f0d3a8250633, MethodID: 1, InterfaceName: "process.capnp:Process", - MethodName: "stop", + MethodName: "kill", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Stop(ctx, Process_stop{call}) - }, - }) - - methods = append(methods, server.Method{ - Method: capnp.Method{ - InterfaceID: 0xda23f0d3a8250633, - MethodID: 2, - InterfaceName: "process.capnp:Process", - MethodName: "wait", - }, - Impl: func(ctx context.Context, call *server.Call) error { - return s.Wait(ctx, Process_wait{call}) + return s.Kill(ctx, Process_kill{call}) }, }) return methods } -// Process_start holds the state for a server call to Process.start. +// Process_wait holds the state for a server call to Process.wait. // See server.Call for documentation. -type Process_start struct { +type Process_wait struct { *server.Call } // Args returns the call's arguments. -func (c Process_start) Args() Process_start_Params { - return Process_start_Params(c.Call.Args()) +func (c Process_wait) Args() Process_wait_Params { + return Process_wait_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Process_start) AllocResults() (Process_start_Results, error) { - r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(r), err +func (c Process_wait) AllocResults() (Process_wait_Results, error) { + r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(r), err } -// Process_stop holds the state for a server call to Process.stop. +// Process_kill holds the state for a server call to Process.kill. // See server.Call for documentation. -type Process_stop struct { +type Process_kill struct { *server.Call } // Args returns the call's arguments. -func (c Process_stop) Args() Process_stop_Params { - return Process_stop_Params(c.Call.Args()) +func (c Process_kill) Args() Process_kill_Params { + return Process_kill_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Process_stop) AllocResults() (Process_stop_Results, error) { +func (c Process_kill) AllocResults() (Process_kill_Results, error) { r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(r), err -} - -// Process_wait holds the state for a server call to Process.wait. -// See server.Call for documentation. -type Process_wait struct { - *server.Call -} - -// Args returns the call's arguments. -func (c Process_wait) Args() Process_wait_Params { - return Process_wait_Params(c.Call.Args()) -} - -// AllocResults allocates the results struct. -func (c Process_wait) AllocResults() (Process_wait_Results, error) { - r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(r), err + return Process_kill_Results(r), err } // Process_List is a list of Process. @@ -615,451 +546,311 @@ func NewProcess_List(s *capnp.Segment, sz int32) (Process_List, error) { return capnp.CapList[Process](l), err } -type Process_start_Params capnp.Struct +type Process_wait_Params capnp.Struct -// Process_start_Params_TypeID is the unique identifier for the type Process_start_Params. -const Process_start_Params_TypeID = 0xf9694ae208dbb3e3 +// Process_wait_Params_TypeID is the unique identifier for the type Process_wait_Params. +const Process_wait_Params_TypeID = 0xf9694ae208dbb3e3 -func NewProcess_start_Params(s *capnp.Segment) (Process_start_Params, error) { +func NewProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Params(st), err + return Process_wait_Params(st), err } -func NewRootProcess_start_Params(s *capnp.Segment) (Process_start_Params, error) { +func NewRootProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Params(st), err + return Process_wait_Params(st), err } -func ReadRootProcess_start_Params(msg *capnp.Message) (Process_start_Params, error) { +func ReadRootProcess_wait_Params(msg *capnp.Message) (Process_wait_Params, error) { root, err := msg.Root() - return Process_start_Params(root.Struct()), err + return Process_wait_Params(root.Struct()), err } -func (s Process_start_Params) String() string { +func (s Process_wait_Params) String() string { str, _ := text.Marshal(0xf9694ae208dbb3e3, capnp.Struct(s)) return str } -func (s Process_start_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_wait_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_start_Params) DecodeFromPtr(p capnp.Ptr) Process_start_Params { - return Process_start_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_wait_Params) DecodeFromPtr(p capnp.Ptr) Process_wait_Params { + return Process_wait_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_start_Params) ToPtr() capnp.Ptr { +func (s Process_wait_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_start_Params) IsValid() bool { +func (s Process_wait_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_start_Params) Message() *capnp.Message { +func (s Process_wait_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_start_Params) Segment() *capnp.Segment { +func (s Process_wait_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_start_Params_List is a list of Process_start_Params. -type Process_start_Params_List = capnp.StructList[Process_start_Params] +// Process_wait_Params_List is a list of Process_wait_Params. +type Process_wait_Params_List = capnp.StructList[Process_wait_Params] -// NewProcess_start_Params creates a new list of Process_start_Params. -func NewProcess_start_Params_List(s *capnp.Segment, sz int32) (Process_start_Params_List, error) { +// NewProcess_wait_Params creates a new list of Process_wait_Params. +func NewProcess_wait_Params_List(s *capnp.Segment, sz int32) (Process_wait_Params_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_start_Params](l), err + return capnp.StructList[Process_wait_Params](l), err } -// Process_start_Params_Future is a wrapper for a Process_start_Params promised by a client call. -type Process_start_Params_Future struct{ *capnp.Future } +// Process_wait_Params_Future is a wrapper for a Process_wait_Params promised by a client call. +type Process_wait_Params_Future struct{ *capnp.Future } -func (f Process_start_Params_Future) Struct() (Process_start_Params, error) { +func (f Process_wait_Params_Future) Struct() (Process_wait_Params, error) { p, err := f.Future.Ptr() - return Process_start_Params(p.Struct()), err + return Process_wait_Params(p.Struct()), err } -type Process_start_Results capnp.Struct +type Process_wait_Results capnp.Struct -// Process_start_Results_TypeID is the unique identifier for the type Process_start_Results. -const Process_start_Results_TypeID = 0xd72ab4a0243047ac +// Process_wait_Results_TypeID is the unique identifier for the type Process_wait_Results. +const Process_wait_Results_TypeID = 0xd72ab4a0243047ac -func NewProcess_start_Results(s *capnp.Segment) (Process_start_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(st), err +func NewProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(st), err } -func NewRootProcess_start_Results(s *capnp.Segment) (Process_start_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(st), err +func NewRootProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(st), err } -func ReadRootProcess_start_Results(msg *capnp.Message) (Process_start_Results, error) { +func ReadRootProcess_wait_Results(msg *capnp.Message) (Process_wait_Results, error) { root, err := msg.Root() - return Process_start_Results(root.Struct()), err + return Process_wait_Results(root.Struct()), err } -func (s Process_start_Results) String() string { +func (s Process_wait_Results) String() string { str, _ := text.Marshal(0xd72ab4a0243047ac, capnp.Struct(s)) return str } -func (s Process_start_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_wait_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_start_Results) DecodeFromPtr(p capnp.Ptr) Process_start_Results { - return Process_start_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_wait_Results) DecodeFromPtr(p capnp.Ptr) Process_wait_Results { + return Process_wait_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_start_Results) ToPtr() capnp.Ptr { +func (s Process_wait_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_start_Results) IsValid() bool { +func (s Process_wait_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_start_Results) Message() *capnp.Message { +func (s Process_wait_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_start_Results) Segment() *capnp.Segment { +func (s Process_wait_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } - -// Process_start_Results_List is a list of Process_start_Results. -type Process_start_Results_List = capnp.StructList[Process_start_Results] - -// NewProcess_start_Results creates a new list of Process_start_Results. -func NewProcess_start_Results_List(s *capnp.Segment, sz int32) (Process_start_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_start_Results](l), err -} - -// Process_start_Results_Future is a wrapper for a Process_start_Results promised by a client call. -type Process_start_Results_Future struct{ *capnp.Future } - -func (f Process_start_Results_Future) Struct() (Process_start_Results, error) { - p, err := f.Future.Ptr() - return Process_start_Results(p.Struct()), err -} - -type Process_stop_Params capnp.Struct - -// Process_stop_Params_TypeID is the unique identifier for the type Process_stop_Params. -const Process_stop_Params_TypeID = 0xeea7ae19b02f5d47 - -func NewProcess_stop_Params(s *capnp.Segment) (Process_stop_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Params(st), err -} - -func NewRootProcess_stop_Params(s *capnp.Segment) (Process_stop_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Params(st), err -} - -func ReadRootProcess_stop_Params(msg *capnp.Message) (Process_stop_Params, error) { - root, err := msg.Root() - return Process_stop_Params(root.Struct()), err -} - -func (s Process_stop_Params) String() string { - str, _ := text.Marshal(0xeea7ae19b02f5d47, capnp.Struct(s)) - return str -} - -func (s Process_stop_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { - return capnp.Struct(s).EncodeAsPtr(seg) -} - -func (Process_stop_Params) DecodeFromPtr(p capnp.Ptr) Process_stop_Params { - return Process_stop_Params(capnp.Struct{}.DecodeFromPtr(p)) -} - -func (s Process_stop_Params) ToPtr() capnp.Ptr { - return capnp.Struct(s).ToPtr() -} -func (s Process_stop_Params) IsValid() bool { - return capnp.Struct(s).IsValid() -} - -func (s Process_stop_Params) Message() *capnp.Message { - return capnp.Struct(s).Message() +func (s Process_wait_Results) ExitCode() uint32 { + return capnp.Struct(s).Uint32(0) } -func (s Process_stop_Params) Segment() *capnp.Segment { - return capnp.Struct(s).Segment() +func (s Process_wait_Results) SetExitCode(v uint32) { + capnp.Struct(s).SetUint32(0, v) } -// Process_stop_Params_List is a list of Process_stop_Params. -type Process_stop_Params_List = capnp.StructList[Process_stop_Params] +// Process_wait_Results_List is a list of Process_wait_Results. +type Process_wait_Results_List = capnp.StructList[Process_wait_Results] -// NewProcess_stop_Params creates a new list of Process_stop_Params. -func NewProcess_stop_Params_List(s *capnp.Segment, sz int32) (Process_stop_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_stop_Params](l), err +// NewProcess_wait_Results creates a new list of Process_wait_Results. +func NewProcess_wait_Results_List(s *capnp.Segment, sz int32) (Process_wait_Results_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz) + return capnp.StructList[Process_wait_Results](l), err } -// Process_stop_Params_Future is a wrapper for a Process_stop_Params promised by a client call. -type Process_stop_Params_Future struct{ *capnp.Future } +// Process_wait_Results_Future is a wrapper for a Process_wait_Results promised by a client call. +type Process_wait_Results_Future struct{ *capnp.Future } -func (f Process_stop_Params_Future) Struct() (Process_stop_Params, error) { +func (f Process_wait_Results_Future) Struct() (Process_wait_Results, error) { p, err := f.Future.Ptr() - return Process_stop_Params(p.Struct()), err + return Process_wait_Results(p.Struct()), err } -type Process_stop_Results capnp.Struct +type Process_kill_Params capnp.Struct -// Process_stop_Results_TypeID is the unique identifier for the type Process_stop_Results. -const Process_stop_Results_TypeID = 0xc53168b273d497ee +// Process_kill_Params_TypeID is the unique identifier for the type Process_kill_Params. +const Process_kill_Params_TypeID = 0xeea7ae19b02f5d47 -func NewProcess_stop_Results(s *capnp.Segment) (Process_stop_Results, error) { +func NewProcess_kill_Params(s *capnp.Segment) (Process_kill_Params, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(st), err + return Process_kill_Params(st), err } -func NewRootProcess_stop_Results(s *capnp.Segment) (Process_stop_Results, error) { +func NewRootProcess_kill_Params(s *capnp.Segment) (Process_kill_Params, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(st), err + return Process_kill_Params(st), err } -func ReadRootProcess_stop_Results(msg *capnp.Message) (Process_stop_Results, error) { +func ReadRootProcess_kill_Params(msg *capnp.Message) (Process_kill_Params, error) { root, err := msg.Root() - return Process_stop_Results(root.Struct()), err + return Process_kill_Params(root.Struct()), err } -func (s Process_stop_Results) String() string { - str, _ := text.Marshal(0xc53168b273d497ee, capnp.Struct(s)) +func (s Process_kill_Params) String() string { + str, _ := text.Marshal(0xeea7ae19b02f5d47, capnp.Struct(s)) return str } -func (s Process_stop_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_kill_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_stop_Results) DecodeFromPtr(p capnp.Ptr) Process_stop_Results { - return Process_stop_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_kill_Params) DecodeFromPtr(p capnp.Ptr) Process_kill_Params { + return Process_kill_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_stop_Results) ToPtr() capnp.Ptr { +func (s Process_kill_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_stop_Results) IsValid() bool { +func (s Process_kill_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_stop_Results) Message() *capnp.Message { +func (s Process_kill_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_stop_Results) Segment() *capnp.Segment { +func (s Process_kill_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_stop_Results_List is a list of Process_stop_Results. -type Process_stop_Results_List = capnp.StructList[Process_stop_Results] +// Process_kill_Params_List is a list of Process_kill_Params. +type Process_kill_Params_List = capnp.StructList[Process_kill_Params] -// NewProcess_stop_Results creates a new list of Process_stop_Results. -func NewProcess_stop_Results_List(s *capnp.Segment, sz int32) (Process_stop_Results_List, error) { +// NewProcess_kill_Params creates a new list of Process_kill_Params. +func NewProcess_kill_Params_List(s *capnp.Segment, sz int32) (Process_kill_Params_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_stop_Results](l), err + return capnp.StructList[Process_kill_Params](l), err } -// Process_stop_Results_Future is a wrapper for a Process_stop_Results promised by a client call. -type Process_stop_Results_Future struct{ *capnp.Future } +// Process_kill_Params_Future is a wrapper for a Process_kill_Params promised by a client call. +type Process_kill_Params_Future struct{ *capnp.Future } -func (f Process_stop_Results_Future) Struct() (Process_stop_Results, error) { +func (f Process_kill_Params_Future) Struct() (Process_kill_Params, error) { p, err := f.Future.Ptr() - return Process_stop_Results(p.Struct()), err + return Process_kill_Params(p.Struct()), err } -type Process_wait_Params capnp.Struct +type Process_kill_Results capnp.Struct -// Process_wait_Params_TypeID is the unique identifier for the type Process_wait_Params. -const Process_wait_Params_TypeID = 0xd22f75df06c187e8 +// Process_kill_Results_TypeID is the unique identifier for the type Process_kill_Results. +const Process_kill_Results_TypeID = 0xc53168b273d497ee -func NewProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { +func NewProcess_kill_Results(s *capnp.Segment) (Process_kill_Results, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_wait_Params(st), err + return Process_kill_Results(st), err } -func NewRootProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { +func NewRootProcess_kill_Results(s *capnp.Segment) (Process_kill_Results, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_wait_Params(st), err + return Process_kill_Results(st), err } -func ReadRootProcess_wait_Params(msg *capnp.Message) (Process_wait_Params, error) { +func ReadRootProcess_kill_Results(msg *capnp.Message) (Process_kill_Results, error) { root, err := msg.Root() - return Process_wait_Params(root.Struct()), err + return Process_kill_Results(root.Struct()), err } -func (s Process_wait_Params) String() string { - str, _ := text.Marshal(0xd22f75df06c187e8, capnp.Struct(s)) +func (s Process_kill_Results) String() string { + str, _ := text.Marshal(0xc53168b273d497ee, capnp.Struct(s)) return str } -func (s Process_wait_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_kill_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_wait_Params) DecodeFromPtr(p capnp.Ptr) Process_wait_Params { - return Process_wait_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_kill_Results) DecodeFromPtr(p capnp.Ptr) Process_kill_Results { + return Process_kill_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_wait_Params) ToPtr() capnp.Ptr { +func (s Process_kill_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_wait_Params) IsValid() bool { +func (s Process_kill_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_wait_Params) Message() *capnp.Message { +func (s Process_kill_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_wait_Params) Segment() *capnp.Segment { +func (s Process_kill_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_wait_Params_List is a list of Process_wait_Params. -type Process_wait_Params_List = capnp.StructList[Process_wait_Params] +// Process_kill_Results_List is a list of Process_kill_Results. +type Process_kill_Results_List = capnp.StructList[Process_kill_Results] -// NewProcess_wait_Params creates a new list of Process_wait_Params. -func NewProcess_wait_Params_List(s *capnp.Segment, sz int32) (Process_wait_Params_List, error) { +// NewProcess_kill_Results creates a new list of Process_kill_Results. +func NewProcess_kill_Results_List(s *capnp.Segment, sz int32) (Process_kill_Results_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_wait_Params](l), err + return capnp.StructList[Process_kill_Results](l), err } -// Process_wait_Params_Future is a wrapper for a Process_wait_Params promised by a client call. -type Process_wait_Params_Future struct{ *capnp.Future } +// Process_kill_Results_Future is a wrapper for a Process_kill_Results promised by a client call. +type Process_kill_Results_Future struct{ *capnp.Future } -func (f Process_wait_Params_Future) Struct() (Process_wait_Params, error) { +func (f Process_kill_Results_Future) Struct() (Process_kill_Results, error) { p, err := f.Future.Ptr() - return Process_wait_Params(p.Struct()), err -} - -type Process_wait_Results capnp.Struct - -// Process_wait_Results_TypeID is the unique identifier for the type Process_wait_Results. -const Process_wait_Results_TypeID = 0x9d6074459fa0602b - -func NewProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(st), err -} - -func NewRootProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(st), err -} - -func ReadRootProcess_wait_Results(msg *capnp.Message) (Process_wait_Results, error) { - root, err := msg.Root() - return Process_wait_Results(root.Struct()), err -} - -func (s Process_wait_Results) String() string { - str, _ := text.Marshal(0x9d6074459fa0602b, capnp.Struct(s)) - return str -} - -func (s Process_wait_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { - return capnp.Struct(s).EncodeAsPtr(seg) -} - -func (Process_wait_Results) DecodeFromPtr(p capnp.Ptr) Process_wait_Results { - return Process_wait_Results(capnp.Struct{}.DecodeFromPtr(p)) -} - -func (s Process_wait_Results) ToPtr() capnp.Ptr { - return capnp.Struct(s).ToPtr() -} -func (s Process_wait_Results) IsValid() bool { - return capnp.Struct(s).IsValid() -} - -func (s Process_wait_Results) Message() *capnp.Message { - return capnp.Struct(s).Message() -} - -func (s Process_wait_Results) Segment() *capnp.Segment { - return capnp.Struct(s).Segment() -} -func (s Process_wait_Results) ExitCode() uint32 { - return capnp.Struct(s).Uint32(0) -} - -func (s Process_wait_Results) SetExitCode(v uint32) { - capnp.Struct(s).SetUint32(0, v) -} - -// Process_wait_Results_List is a list of Process_wait_Results. -type Process_wait_Results_List = capnp.StructList[Process_wait_Results] - -// NewProcess_wait_Results creates a new list of Process_wait_Results. -func NewProcess_wait_Results_List(s *capnp.Segment, sz int32) (Process_wait_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz) - return capnp.StructList[Process_wait_Results](l), err -} - -// Process_wait_Results_Future is a wrapper for a Process_wait_Results promised by a client call. -type Process_wait_Results_Future struct{ *capnp.Future } - -func (f Process_wait_Results_Future) Struct() (Process_wait_Results, error) { - p, err := f.Future.Ptr() - return Process_wait_Results(p.Struct()), err -} - -const schema_9a51e53177277763 = "x\xda|\x92Oh\x13M\x18\xc6\xdfgf\xd3\x0d|" + - "\xc9W\xa6[\xab\xf6R\xac\x15\xb5\xd26\xb1\x1eT\x94" + - "\x06%\x14zq\xc7\x9b\x82\xd25.\x18h\x93\xb8\x7f" + - "H{\x10\xe9A\xc4\xa3\x8a\x88\x8aX\x0fR\x05\xd1R" + - "\xbdX\xf1\xe0\xa1x\x95\xa8\x14\xf4 (\x82\x08\x16\xf1" + - "\xe6ie6\xd95\xad\xa6\xb7\x19\xdew\x9e\xf7y\x7f" + - "\xf3dF\x90\xd3\xb2\xe9e\x8d\x98\xdc\x9bh\x0bv\x8d" + - "\xcf\xde\xc9{\xe3\xb7Iv\x01D\x9aN4,Y7" + - "\x08\xc616B\x08j\xfe\xcc\xbd\xc5\x93\x83\x8fI\xfc" + - "\xcf\x83Bu{5\xfbE\xde$\x82q\x8e-\x1a\x17" + - "\x98Nd\xcc\xb0Q\xe3\x81:\x05\xb7^\xd7\xe6\xe6\xbb" + - "\x8e<'\xb1\x11D\x09(\xb5\xcb\xac_\xa9\xdd\x08\xd5" + - "V\xae\xbfu\x17\xced\x97HtE\xd3\x9e\xa9iZ" + - "\xf0\xf5\xe2\xcb\xb6\x8f\xfeP\xad\xa9r\x97u\xa8\xca\xc3" + - "\xd1L\xdf\xec\xd3\xfe\xe5\xa6\xca%\xd6\xab*\xc3m\xdb" + - "\xee\xbf\xf9\xb1\xf5\xfd_\xde\xce\xb2\x05c:\xf4\xe6\xb3" + - "W\xc6\xf7\xd0\xdb\xe8\x89\xa1\xf9\xcd\x8f\xe6V\x9ad\xde" + - "\xd5\x07t\\\xbdr\xed\xdb\xc1\xff~6\\\xab\xee\xe1" + - "\x17j\x02\x8c%V%\x04\x9f\x9f|H~\x1a+\xfe" + - "jz:\xc0\xbbA\x99\xa0\xe2\x94\x0b\xb6\xeb\x0e\xf2\x82" + - "U)U\xf6\x9b\x8dk\xd5*z}Gm\xd7\x9f\xe0" + - "\x9e+5\xae\x11i \x12\xe91\"\x99\xe2\x90\x9b\x18" + - "\x02{\xaa\xe8\x1d.\x9f\xb6\x89\x08IbH\x12b=" + - "\xd4\xf5\xf2S#v\xc1\xf7\xca\x8e\x09H\x8d'\x88b" + - "\xb3\x88X\x0b\xb1\x9b\x98H\xe8=n\xc5\xaa\x96r0" + - "\x81\xb5\xb6\xf2Su\x95\xc1\xb0E\x19k\xf7'V\x1b" + - ";D$\x93\x1c\xb2\x93\xe1|\xe35\xc4\x1f\xc0\x04\x08" + - "B\xabu]\xaf\\\x89\xd7]\x97\x89i9\xd6$\xdc" + - "\xd6B\x96S\x07\xa7O4)!\xea\xea\x09\xef\x0aF" + - "*\x84\x11}\x0c\xa2\x8c\x08\xa9`\xe4u \xfeoD" + - "\x99\x13\xfb\xfa\x89\x89\x01\x1d,\x0e\x1b\xa2\xf8\x8b-\xaa" + - "\xb6A\xef\x09\x1d\xe4\xd0\xaeV\xca\xa1]\x99\xfe'\xd2" + - "U\xab\xb7\xd8j\x0dv\xd3rtk\xd2\x95\xc9\x98\xfa" + - "N\x15\x87\x1d\x1cr\x0f\x83\x00:\x01@d\x8f\x13\xc9" + - "\x0c\x87<\xc0\x10\x9c\x9a\xf6\xec(#ibH\x13\x02" + - "\xbb\xe49\xd3f\xb9H\xbc\xe4!E\x0c)\"\x81^" + - "\xdd\xf1K\xebsU6\xf9\xa4\xfb;\x00\x00\xff\xff\xdc" + - "a-[" + return Process_kill_Results(p.Struct()), err +} + +const schema_9a51e53177277763 = "x\xda|\x921h\x13Q\x18\xc7\xff\xffw/\xbd\x03" + + "=\xc3\xebi\xb4\x82\x08\xdaP\xe8\x10\x13\x8a\x8b \x0d" + + "\x8a\x04\x0bb\x9e\xbbB<\x0f\x0c&&\xe4.$N" + + "\xe2 \xee\x8a\x88\x8a\xe0\"u\x10-\xd5\xa9\xce\xeeR" + + "\x05A7\xc5\xc5\xa1\x88[\x079y\xd7\\<\xa9\xe9" + + "v\x8f\xef\xfb\xfe\xff\xff\xf7\xfb\xae,Y\x95\x15wN" + + "B\xe8rn*^\xef\xdfz\xb6v\xa9\xf4\x0aj\x8f" + + "\x15\xfb\x83\xb9A\xe5\xbb~\x04\xd0\xdb\xe4\x9aGa\x03" + + "\xdeo\xd6\xbc\xa2\xf9\x8a\x1f\xbf__^)\x9c\x7f\x0b" + + "\xb5\x9f@\x8e6\xb0\xe0\x8a#\x04\xbd}b\x11\x8c7" + + "\x1e|\x0cW\xafV\xdeA\x15\x08HS?.\x0e\x12" + + "2~Q+\xcf>}3\xff\x09\xba\xc0\xb4t\xc8\x94" + + "\xe8\x15\x93\xd1\x85\xa9\xe2\xf3\x0f?\x8f~\xde\x16\xe4\xac" + + "X\xf5t\x12\xe4\x9c\xb8\xe3=I\x82\xd4.\x1e[\x99" + + "y\xb9\xbc\x91\xf1\xb9-\xa6\x8d\xcf\xf4\xbd\xbb\xf7\x7f\x9c" + + "\xdc\xf5+\x1b\xb1\xbd\xe5\xd3O|\xbe\xbd\xfe\xe2|]" + + "jnfF\x1f\x9a\xd1r\xdc\xedu\xfc \x0cK\xf4" + + "\x1b\xdd\xeb\xdd\x13g\x86\x8b\x81\xdf\x8f:\xbd:\xa9\xa5" + + "\x95\x03\xc6\xe2LA(5\x0f\xa1rv>\x18\x06~" + + "\x95ur\xacb\xa5*[\"%\xd31{!\x08\xfb" + + "v+\x0a\xb5\xb4$ \x09(\xf7\x14\xa0\x1d\x8bz\xaf" + + "\xe0\xcd\xd10\xd5_\x1c \x15\xb6\xc9\xd6G\xcfk\xcd" + + "V+QmYQ8\xa9i\xd0hF\xe3\xa6\xac\xf5" + + "\x12\xa0w[\xd4\x07\x04\xe3`\xd8\x8cNw\xae\x04\x00" + + "\xe8@\xd0\xc9\x982\xd5;\x9c\xbc\x0d\x10'\x01\x92\xc2" + + "dz^U1@\x8a69\xbe\x11\xd3\x9fB\xcd\x98" + + "\x9ak\xe7M\x9e*\xf3&\xfb\x7f\x99\xfd\xb3\\\xbd\xd1" + + "k\xb4\x19\xee\xcc\xd54Y\xed\x89\xbb]\xbe\x11\x05\xfe" + + "h7\x17\x82\xeed\xa0\x09\xab\x91\xe7\x9f\x00\x00\x00\xff" + + "\xff8\xaa\xe7q" func RegisterSchema(reg *schemas.Registry) { reg.Register(&schemas.Schema{ String: schema_9a51e53177277763, Nodes: []uint64{ - 0x9d6074459fa0602b, 0xaf2e5ebaa58175d2, 0xbb4f16b0a7d2d09b, 0xc53168b273d497ee, - 0xd22f75df06c187e8, 0xd72ab4a0243047ac, 0xda23f0d3a8250633, 0xeea7ae19b02f5d47, diff --git a/internal/cmd/cluster/process.go b/internal/cmd/cluster/process.go index 9c82edc4..243aa2b5 100644 --- a/internal/cmd/cluster/process.go +++ b/internal/cmd/cluster/process.go @@ -32,14 +32,9 @@ func runAction() cli.ActionFunc { executor, release := node.Executor(ctx) defer release() - proc, release := executor.Spawn(ctx, src) + proc, release := executor.Exec(ctx, src) defer release() - if err := proc.Start(ctx); err != nil { - return err - } - defer proc.Stop(ctx) - return proc.Wait(ctx) } } diff --git a/pkg/csp/executor.go b/pkg/csp/executor.go index 8ffd54b1..ce2e9cfe 100644 --- a/pkg/csp/executor.go +++ b/pkg/csp/executor.go @@ -4,7 +4,7 @@ import ( "context" "crypto/rand" "encoding/hex" - "fmt" + "errors" capnp "capnproto.org/go/capnp/v3" "github.com/tetratelabs/wazero" @@ -39,80 +39,98 @@ func (ex Executor) Release() { capnp.Client(ex).Release() } -func (ex Executor) Spawn(ctx context.Context, src []byte) (Proc, capnp.ReleaseFunc) { - f, release := api.Executor(ex).Spawn(ctx, func(ps api.Executor_spawn_Params) error { - return ps.SetByteCode(src) +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) }) return Proc(f.Process()), release } -// Server is the main Executor implementation. It spawns WebAssembly- -// based processes. The zero-value Server panics. -type Server struct { +// Runtime is the main Executor implementation. It spawns WebAssembly- +// based processes. The zero-value Runtime panics. +type Runtime struct { Runtime wazero.Runtime } // Executor provides the Executor capability. -func (wx Server) Executor() Executor { - return Executor(api.Executor_ServerToClient(wx)) +func (r Runtime) Executor() Executor { + return Executor(api.Executor_ServerToClient(r)) } -// Spawn a process by creating a process server and converting it into -// a capability as a response to the call. -func (wx Server) Spawn(ctx context.Context, call api.Executor_spawn) error { +func (r Runtime) Exec(ctx context.Context, call api.Executor_exec) error { res, err := call.AllocResults() if err != nil { return err } - mod, err := wx.loadModule(ctx, call.Args()) + p, err := r.mkproc(ctx, call.Args()) if err != nil { return err } - p, err := wx.mkproc(ctx, mod, call.Args()) - if err == nil { - err = res.SetProcess(api.Process_ServerToClient(p)) - } - - return err + return res.SetProcess(api.Process_ServerToClient(p)) } -func (wx Server) mkproc(ctx context.Context, mod wasm.Module, args api.Executor_spawn_Params) (*process, error) { - name, err := args.EntryPoint() +func (r Runtime) mkproc(ctx context.Context, args api.Executor_exec_Params) (*process, error) { + mod, err := r.mkmod(ctx, args) if err != nil { return nil, err } - var proc process - if proc.fn = mod.ExportedFunction(name); proc.fn == nil { - err = fmt.Errorf("module %s: %s not found", mod.Name(), name) + fn := mod.ExportedFunction("_start") + if fn == nil { + return nil, errors.New("ww: missing export: _start") } - return &proc, err + done, cancel := r.spawn(fn) + return &process{ + done: done, + cancel: cancel, + }, nil } -func (wx Server) loadModule(ctx context.Context, args api.Executor_spawn_Params) (wasm.Module, error) { - bc, err := args.ByteCode() +func (r Runtime) mkmod(ctx context.Context, args api.Executor_exec_Params) (wasm.Module, error) { + bc, err := args.Bytecode() if err != nil { return nil, err } name := ByteCode(bc).String() - config := wazero. + + // TODO(perf): cache compiled modules so that we can instantiate module + // instances for concurrent use. + module, err := r.Runtime.CompileModule(ctx, bc) + if err != nil { + return nil, err + } + + return r.Runtime.InstantiateModule(ctx, module, wazero. NewModuleConfig(). WithName(name). - WithRandSource(rand.Reader) + WithStartFunctions(). // disable automatic calling of _start (main) + WithRandSource(rand.Reader)) +} +func (r Runtime) spawn(fn wasm.Function) (<-chan execResult, context.CancelFunc) { + out := make(chan execResult, 1) - if mod := wx.Runtime.Module(name); mod != nil { - return mod, nil - } + // NOTE: we use context.Background instead of the context obtained from the + // rpc handler. This ensures that a process can continue to run after + // the rpc handler has returned. Note also that this context is bound + // to the application lifetime, so processes cannot block a shutdown. + ctx, cancel := context.WithCancel(context.Background()) - module, err := wx.Runtime.CompileModule(ctx, bc) - if err != nil { - return nil, err - } + go func() { + defer close(out) + defer cancel() + + // vs, err := fn.Call(wazergo.WithModuleInstance(ctx, r.HostModule)) + vs, err := fn.Call(ctx) + out <- execResult{ + Values: vs, + Err: err, + } + }() - return wx.Runtime.InstantiateModule(ctx, module, config) + return out, cancel } diff --git a/pkg/csp/executor_test.go b/pkg/csp/executor_test.go deleted file mode 100644 index 4e30b28c..00000000 --- a/pkg/csp/executor_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package csp_test - -import ( - "context" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/tetratelabs/wazero" - "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" - "github.com/tetratelabs/wazero/sys" - "github.com/wetware/ww/pkg/csp" -) - -func TestExecutor(t *testing.T) { - t.Parallel() - - r := wazero.NewRuntime(context.Background()) - wasi_snapshot_preview1.MustInstantiate(context.Background(), r) - - exec := csp.Server{Runtime: r}.Executor() - defer exec.Release() - - proc, release := exec.Spawn(context.Background(), testdata()) - defer release() - - err := proc.Start(context.Background()) - require.NoError(t, err, "should start process") - - err = proc.Wait(context.Background()) - require.Error(t, err, "should return an error from process") - - ee, ok := err.(*sys.ExitError) - require.True(t, ok, "should return sys.ExitError") - assert.Equal(t, uint32(99), ee.ExitCode()) -} - -func testdata() []byte { - b, err := os.ReadFile("testdata/main.wasm") - if err != nil { - panic(err) - } - - return b -} diff --git a/pkg/csp/proc.go b/pkg/csp/proc.go index 1cab4271..6898718b 100644 --- a/pkg/csp/proc.go +++ b/pkg/csp/proc.go @@ -3,10 +3,8 @@ package csp import ( "context" "errors" - "sync/atomic" capnp "capnproto.org/go/capnp/v3" - wasm "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/sys" casm "github.com/wetware/casm/pkg" @@ -26,18 +24,10 @@ func (p Proc) AddRef() Proc { func (p Proc) Release() { capnp.Client(p).Release() - -} - -func (p Proc) Start(ctx context.Context) error { - f, release := api.Process(p).Start(ctx, nil) - defer release() - - return casm.Future(f).Await(ctx) } -func (p Proc) Stop(ctx context.Context) error { - f, release := api.Process(p).Stop(ctx, nil) +func (p Proc) Kill(ctx context.Context) error { + f, release := api.Process(p).Kill(ctx, nil) defer release() return casm.Future(f).Await(ctx) @@ -61,110 +51,44 @@ func (p Proc) Wait(ctx context.Context) error { // process is the main implementation of the Process capability. type process struct { - fn wasm.Function - handle procHandle -} - -// Stop calls the runtime cancellation function. -func (p *process) Stop(context.Context, api.Process_stop) error { - state := p.handle.Load() - if state.Err == nil { - state.Cancel() - } - - return state.Err + done <-chan execResult + cancel context.CancelFunc + result execResult } -// Start the process in the background. -func (p *process) Start(_ context.Context, call api.Process_start) error { - state := p.handle.Load() - if state.Err != ErrNotStarted { - return state.Err - } - - p.handle.Exec(p.fn) +func (p process) Kill(context.Context, api.Process_kill) error { + p.cancel() return nil } -// Wait for the process to finish running. func (p *process) Wait(ctx context.Context, call api.Process_wait) error { - state := p.handle.Load() - if state.Err == ErrNotStarted { - return state.Err - } - - results, err := call.AllocResults() - if err != nil { - return err - } - - call.Go() - select { + case res, ok := <-p.done: + if ok { + p.result = res + } + case <-ctx.Done(): return ctx.Err() - case <-state.Ctx.Done(): - return p.handle.Bind(results) } -} - -// procHandle encapsulates all the runtime state of a process. Its -// methods are safe for concurrent access. -type procHandle atomic.Pointer[state] - -// Exec sets the current state to ErrRunning, calls the function, and -// then sets the current state to the resulting error. -func (as *procHandle) Exec(fn wasm.Function) { - ctx, cancel := context.WithCancel(context.Background()) - - // set "running" state - (*atomic.Pointer[state])(as).Store(&state{ - Ctx: ctx, - Cancel: cancel, - Err: ErrRunning, - }) - - go func() { - defer cancel() - - // block until function call completes - _, err := fn.Call(ctx) - - // call entrypoint function & set "finished" state - (*atomic.Pointer[state])(as).Store(&state{ - Ctx: ctx, - Cancel: cancel, - Err: err, - }) - }() -} -// Bind the error from the entrypoint function to the results struct. -// Callers MUST NOT call Bind until the function has returned. -func (as *procHandle) Bind(res api.Process_wait_Results) error { - if state := as.Load(); state.Err != nil { - code := state.Err.(*sys.ExitError).ExitCode() - res.SetExitCode(code) + res, err := call.AllocResults() + if err == nil { + err = p.result.Bind(res) } - return nil + return err } -// Load the current state atomically. The resulting resulting state -// defaults to ErrNotStarted. -func (as *procHandle) Load() state { - if s := (*atomic.Pointer[state])(as).Load(); s != nil { - return *s - } +type execResult struct { + Values []uint64 + Err error +} - return state{ - Cancel: func() {}, - Err: ErrNotStarted, +func (r execResult) Bind(res api.Process_wait_Results) error { + if r.Err != nil { + res.SetExitCode(r.Err.(*sys.ExitError).ExitCode()) } -} -type state struct { - Ctx context.Context - Cancel context.CancelFunc - Err error + return nil } diff --git a/pkg/csp/testdata/main.go b/pkg/csp/testdata/main.go deleted file mode 100644 index 50622ece..00000000 --- a/pkg/csp/testdata/main.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import "os" - -/* - build with: tinygo build -o pkg/process/testdata/main.wasm -target=wasi -scheduler=none pkg/process/testdata/main.go -*/ - -//export run -func run() { - os.Exit(99) -} - -func main() {} diff --git a/pkg/csp/testdata/main.wasm b/pkg/csp/testdata/main.wasm deleted file mode 100755 index 457ee8b8..00000000 Binary files a/pkg/csp/testdata/main.wasm and /dev/null differ diff --git a/pkg/server/config.go b/pkg/server/config.go index d41105b9..975336fb 100644 --- a/pkg/server/config.go +++ b/pkg/server/config.go @@ -4,15 +4,17 @@ import ( "context" "time" - "go.uber.org/fx" - + "github.com/lthibault/log" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" + "go.uber.org/fx" + casm "github.com/wetware/casm/pkg" "github.com/wetware/casm/pkg/cluster" "github.com/wetware/casm/pkg/cluster/pulse" "github.com/wetware/casm/pkg/cluster/routing" "github.com/wetware/casm/pkg/debug" + "github.com/wetware/ww/pkg/csp" ) type ClusterConfig struct { @@ -62,10 +64,11 @@ type RuntimeConfig struct { fx.In Ctx context.Context `optional:"true"` + Logger log.Logger `optional:"true"` Config wazero.RuntimeConfig `optional:"true"` } -func (rc RuntimeConfig) New() wazero.Runtime { +func (rc RuntimeConfig) New() csp.Runtime { if rc.Ctx == nil { rc.Ctx = context.Background() } @@ -76,7 +79,10 @@ func (rc RuntimeConfig) New() wazero.Runtime { r := wazero.NewRuntimeWithConfig(rc.Ctx, rc.Config) wasi_snapshot_preview1.MustInstantiate(rc.Ctx, r) - return r + + return csp.Runtime{ + Runtime: r, + } } type DebugConfig struct { diff --git a/pkg/server/server.go b/pkg/server/server.go index df737fcc..d8e68d03 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -11,7 +11,6 @@ import ( casm "github.com/wetware/casm/pkg" "github.com/wetware/casm/pkg/cluster" "github.com/wetware/ww/pkg/anchor" - "github.com/wetware/ww/pkg/csp" "github.com/wetware/ww/pkg/host" "github.com/wetware/ww/pkg/pubsub" ) @@ -71,7 +70,7 @@ func (j Joiner) Join(vat casm.Vat, r Router) (*Node, error) { PubSubProvider: j.pubsub(vat.Logger, r), AnchorProvider: j.anchor(), DebugProvider: j.Debugger.New(), - ExecutorProvider: j.executor(), + ExecutorProvider: j.Runtime.New(), }) return &Node{ @@ -90,9 +89,3 @@ func (j Joiner) pubsub(log log.Logger, router pubsub.TopicJoiner) *pubsub.Server func (j Joiner) anchor() anchor.Server { return anchor.Root() } - -func (j Joiner) executor() csp.Server { - return csp.Server{ - Runtime: j.Runtime.New(), - } -}