csp

package
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2023 License: Apache-2.0, MIT Imports: 8 Imported by: 1

Documentation

Overview

Package csp provides primitives for communicating sequential processes

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRunning    = errors.New("running")
	ErrNotStarted = errors.New("not started")
)

Functions

This section is empty.

Types

type BootContext

type BootContext struct {
	// contains filtered or unexported fields
}

BootContext implements api.BootContext.

func NewBootContext

func NewBootContext() *BootContext

func (*BootContext) Args

func (b *BootContext) Args(ctx context.Context, call api.BootContext_args) error

func (*BootContext) Cap

func (b *BootContext) Cap() api.BootContext

func (*BootContext) Caps

func (b *BootContext) Caps(ctx context.Context, call api.BootContext_caps) error

func (*BootContext) Cid

func (b *BootContext) Cid(ctx context.Context, call api.BootContext_cid) error

func (*BootContext) Empty

func (b *BootContext) Empty() *BootContext

func (*BootContext) Pid

func (b *BootContext) Pid(ctx context.Context, call api.BootContext_pid) error

func (*BootContext) SetCid

func (b *BootContext) SetCid(ctx context.Context, call api.BootContext_setCid) error

func (*BootContext) SetPid

func (b *BootContext) SetPid(ctx context.Context, call api.BootContext_setPid) error

func (*BootContext) WithArgs

func (b *BootContext) WithArgs(args ...string) *BootContext

func (*BootContext) WithCaps

func (b *BootContext) WithCaps(caps ...capnp.Client) (*BootContext, error)

func (*BootContext) WithCid

func (b *BootContext) WithCid(cid cid.Cid) *BootContext

func (*BootContext) WithPid

func (b *BootContext) WithPid(pid uint32) *BootContext

func (*BootContext) WithRawArgs

func (b *BootContext) WithRawArgs(args capnp.TextList) *BootContext

func (*BootContext) WithRawCaps

func (b *BootContext) WithRawCaps(caps capnp.PointerList) *BootContext

type BootCtx

type BootCtx api.BootContext

BootCtx is a wrapper for api.BootContext RPCs.

func (BootCtx) Args

func (b BootCtx) Args(ctx context.Context) ([]string, error)

func (BootCtx) Caps

func (b BootCtx) Caps(ctx context.Context) ([]capnp.Client, error)

func (BootCtx) Cid

func (b BootCtx) Cid(ctx context.Context) (cid.Cid, error)

func (BootCtx) Pid

func (b BootCtx) Pid(ctx context.Context) (uint32, error)

func (BootCtx) SetCid

func (b BootCtx) SetCid(ctx context.Context, cid cid.Cid) error

func (BootCtx) SetPid

func (b BootCtx) SetPid(ctx context.Context, pid uint32) error

type ByteCode

type ByteCode []byte

ByteCode is a representation of arbitrary executable data.

func (ByteCode) Hash

func (b ByteCode) Hash() [32]byte

Hash returns the BLAKE3-256 hash of the byte code. It is suitbale for use as a secure checksum.

func (ByteCode) String

func (b ByteCode) String() string

type Cache

type Cache api.BytecodeCache

func (Cache) Get

func (c Cache) Get(ctx context.Context, cid cid.Cid) ([]byte, error)

Get the bytecode associated to the cid produced by CidFunc(bytecode).

func (Cache) Has

func (c Cache) Has(ctx context.Context, cid cid.Cid) (bool, error)

Has returns whether there is a match for the cid or not.

func (Cache) Put

func (c Cache) Put(ctx context.Context, bc []byte) (cid.Cid, error)

Put a bytecode in the Cache with it's CidFunc as the key.

type Executor

type Executor api.Executor

Executor is a capability that can spawn processes.

func (Executor) AddRef

func (ex Executor) AddRef() Executor

func (Executor) Exec

func (ex Executor) Exec(ctx context.Context, bc []byte, ppid uint32, bCtx api.BootContext) (Proc, capnp.ReleaseFunc)

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 (Executor) ExecFromCache

func (ex Executor) ExecFromCache(ctx context.Context, cid cid.Cid, ppid uint32, bCtx api.BootContext) (Proc, capnp.ReleaseFunc)

ExecFromCache behaves the same way as Exec, but expects the bytecode to be already cached at the executor.

func (Executor) Release

func (ex Executor) Release()

type Proc

type Proc api.Process

func (Proc) AddRef

func (p Proc) AddRef() Proc

func (Proc) Kill

func (p Proc) Kill(ctx context.Context) error

Kill a process and any sub processes it might have spawned.

func (Proc) Release

func (p Proc) Release()

func (Proc) Wait

func (p Proc) Wait(ctx context.Context) error

Directories

Path Synopsis
Package proc provides the WebAssembly host module for Wetware processes
Package proc provides the WebAssembly host module for Wetware processes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL