Documentation
¶
Index ¶
- Constants
- Variables
- func DialWithRetries(addr *net.TCPAddr) (net.Conn, error)
- func ServeModule[T ~capnp.ClientKind](addr *net.TCPAddr, t T)
- type AtomicCounter
- type BytecodeCache
- type Chan
- func (c Chan) AddRef() Chan
- func (c Chan) Client() capnp.Client
- func (c Chan) Close(ctx context.Context) error
- func (c Chan) NewCloser(ctx context.Context) (Closer, capnp.ReleaseFunc)
- func (c Chan) NewRecver(ctx context.Context) (Recver, capnp.ReleaseFunc)
- func (c Chan) NewSendCloser(ctx context.Context) (SendCloser, capnp.ReleaseFunc)
- func (c Chan) NewSender(ctx context.Context) (Sender, capnp.ReleaseFunc)
- func (c Chan) Recv(ctx context.Context) (casm.Future, capnp.ReleaseFunc)
- func (c Chan) Release()
- func (c Chan) Send(ctx context.Context, v Value) error
- type ChanServer
- type CloseServer
- type Closer
- type MethodClose
- type MethodNewCloser
- type MethodNewRecver
- type MethodNewSendCloser
- type MethodNewSender
- type MethodRecv
- type MethodSend
- type ProcNode
- type ProcTree
- func (pt ProcTree) AddToMap(pid uint32, p api.Process_Server)
- func (pt ProcTree) Find(pid uint32) *ProcNode
- func (pt ProcTree) FindParent(pid uint32) *ProcNode
- func (pt ProcTree) Insert(pid, ppid uint32) error
- func (pt *ProcTree) Kill(pid uint32)
- func (pt *ProcTree) NextPid() uint32
- func (pt ProcTree) Pop(pid uint32) *ProcNode
- func (pt *ProcTree) PpidOrInit(ppid uint32) uint32
- func (pt ProcTree) Trim(ctx context.Context)
- type RecvServer
- type Recver
- type Runtime
- type SendCloseServer
- type SendCloser
- func (sc SendCloser) AddRef() SendCloser
- func (sc SendCloser) Client() capnp.Client
- func (sc SendCloser) Close(ctx context.Context) error
- func (sc SendCloser) NewCloser(ctx context.Context) (Closer, capnp.ReleaseFunc)
- func (sc SendCloser) NewSender(ctx context.Context) (Sender, capnp.ReleaseFunc)
- func (sc SendCloser) Release()
- func (sc SendCloser) Send(ctx context.Context, v Value) error
- type SendServer
- type Sender
- type SyncChan
- func (ch *SyncChan) Close(ctx context.Context, call MethodClose) error
- func (ch *SyncChan) NewCloser(ctx context.Context, call MethodNewCloser) error
- func (ch *SyncChan) NewRecver(ctx context.Context, call MethodNewRecver) error
- func (ch *SyncChan) NewSendCloser(ctx context.Context, call MethodNewSendCloser) error
- func (ch *SyncChan) NewSender(ctx context.Context, call MethodNewSender) error
- func (ch *SyncChan) Recv(ctx context.Context, call MethodRecv) error
- func (ch *SyncChan) Send(ctx context.Context, call MethodSend) error
- type Value
Constants ¶
const INIT_PID = 1
Variables ¶
var ( ErrEmpty = errors.New("empty") ErrClosed = errors.New("closed") )
Functions ¶
func DialWithRetries ¶
DialWithRetries dials addr in waitTime intervals until it either succeeds or exceeds maxRetries retries.
func ServeModule ¶
ServeModule ensures the host side of the TCP connection with addr=addr used for CAPNP RPCs is provided by client.
Types ¶
type AtomicCounter ¶
type AtomicCounter struct {
// contains filtered or unexported fields
}
AtomicCounter is an atomic counter that increases the
func NewAtomicCounter ¶
func NewAtomicCounter(start uint32) AtomicCounter
type BytecodeCache ¶
TODO mikel Make BytecodeCache keep a list of the bcs it has sorted by last usage Set and enforce a limited list size and a limited memory size
func (BytecodeCache) Get ¶
func (c BytecodeCache) Get(ctx context.Context, call api.BytecodeCache_get) error
func (BytecodeCache) Has ¶
func (c BytecodeCache) Has(ctx context.Context, call api.BytecodeCache_has) error
func (BytecodeCache) Put ¶
func (c BytecodeCache) Put(ctx context.Context, call api.BytecodeCache_put) error
type Chan ¶
func NewChan ¶
func NewChan(s ChanServer) Chan
func (Chan) NewSendCloser ¶
func (c Chan) NewSendCloser(ctx context.Context) (SendCloser, capnp.ReleaseFunc)
type ChanServer ¶
type ChanServer interface { RecvServer SendCloseServer NewRecver(context.Context, MethodNewRecver) error NewSendCloser(context.Context, MethodNewSendCloser) error }
type CloseServer ¶
type CloseServer interface {
Close(context.Context, MethodClose) error
}
type MethodClose ¶
type MethodClose = api.Closer_close
type MethodNewCloser ¶
type MethodNewCloser = api.SendCloser_newCloser
type MethodNewRecver ¶
type MethodNewRecver = api.Chan_newRecver
type MethodNewSendCloser ¶
type MethodNewSendCloser = api.Chan_newSendCloser
type MethodNewSender ¶
type MethodNewSender = api.SendCloser_newSender
type MethodRecv ¶
type MethodRecv = api.Recver_recv
type MethodSend ¶
type MethodSend = api.Sender_send
type ProcNode ¶
type ProcNode struct { // Pid contais the Process ID. Pid uint32 // Left contains a child process. Left *ProcNode // Right contains a sibling process. Right *ProcNode }
ProcNode represents a process in the process tree.
type ProcTree ¶
type ProcTree struct { // TODO move context out of tree Ctx context.Context // PIDC is a couter that increases to assign new PIDs. PIDC AtomicCounter // TPC keeps track of the number of processes in the tree. TPC AtomicCounter // Root of the process tree. Root *ProcNode // Map of processes associated to their PIDs. MUST be initialized. Map map[uint32]api.Process_Server }
ProcTree represents the process tree of an executor. It is represented a binary tree, in which the left branch of a node represents a child process, while the right branch represents a sibling process (shares the same parent). TODO: thread safety.
func NewProcTree ¶
NewProcTree is the default constuctor for ProcTree, but it may also be maually constructed.
func (ProcTree) FindParent ¶
FindParent returns the parent of the process with PID=pid. nil if not found.
func (*ProcTree) NextPid ¶
NextPid returns the next avaiable PID and ensures it does not collide with any existing processes.
func (ProcTree) Pop ¶
Pop removes the node with PID=pid and replaces it with a sibling in the process tree.
func (*ProcTree) PpidOrInit ¶
ppidOrInit checks for a process with pid=ppid and returns ppid if found, INIT_PID otherwise.
type RecvServer ¶
type RecvServer interface {
Recv(context.Context, MethodRecv) error
}
type Runtime ¶
type Runtime struct { Runtime wazero.Runtime Cache BytecodeCache Tree ProcTree // HostModule is unused for now. HostModule *wazergo.ModuleInstance[*proc.Module] }
Runtime is the main Executor implementation. It spawns WebAssembly- based processes. The zero-value Runtime panics.
func (Runtime) ExecCached ¶
type SendCloseServer ¶
type SendCloseServer interface { SendServer CloseServer NewSender(context.Context, MethodNewSender) error NewCloser(context.Context, MethodNewCloser) error }
type SendCloser ¶
type SendCloser api.SendCloser
func NewSendCloser ¶
func NewSendCloser(sc SendCloseServer) SendCloser
func (SendCloser) AddRef ¶
func (sc SendCloser) AddRef() SendCloser
func (SendCloser) Client ¶
func (sc SendCloser) Client() capnp.Client
func (SendCloser) NewCloser ¶
func (sc SendCloser) NewCloser(ctx context.Context) (Closer, capnp.ReleaseFunc)
func (SendCloser) NewSender ¶
func (sc SendCloser) NewSender(ctx context.Context) (Sender, capnp.ReleaseFunc)
func (SendCloser) Release ¶
func (sc SendCloser) Release()
type SendServer ¶
type SendServer interface {
Send(context.Context, MethodSend) error
}
type SyncChan ¶
type SyncChan struct {
// contains filtered or unexported fields
}
SyncChan is a synchronous channel server. Both senders and receivers will block until a matching call arrives.
The zero-value SyncChan is ready to use.
func (*SyncChan) NewCloser ¶
func (ch *SyncChan) NewCloser(ctx context.Context, call MethodNewCloser) error
func (*SyncChan) NewRecver ¶
func (ch *SyncChan) NewRecver(ctx context.Context, call MethodNewRecver) error
func (*SyncChan) NewSendCloser ¶
func (ch *SyncChan) NewSendCloser(ctx context.Context, call MethodNewSendCloser) error
type Value ¶
type Value func(api.Sender_send_Params) error
func Client ¶
func Client[T ~capnp.ClientKind](t T) Value
Client takes any client-like type and converts it into a value capable of being sent through a channel.
func Data ¶
Data takes any []byte-like type and converts it into a value capable of being sent through a channel.
func List ¶
func List[T ~capnp.ListKind](t T) Value
List takes any capnp list and converts it into a value capable of being sent through a channel.
func Ptr ¶
func Ptr(ptr capnp.Ptr) Value
Ptr takes any capnp pointer and converts it into a value capable of being sent through a channel.