Documentation ¶
Index ¶
- type Pool
- func (p *Pool) Acquire(ctx context.Context, metrics metrics.Metrics) (*VM, error)
- func (p *Pool) Close()
- func (p *Pool) ParsedData() (int32, []byte)
- func (p *Pool) Policy() []byte
- func (p *Pool) Release(vm *VM, metrics metrics.Metrics)
- func (p *Pool) RemoveDataPath(ctx context.Context, path []string) error
- func (p *Pool) SetDataPath(ctx context.Context, path []string, value interface{}) error
- func (p *Pool) SetPolicyData(ctx context.Context, policy []byte, data []byte) error
- func (p *Pool) Size() int
- func (p *Pool) Wait(i int) *VM
- type VM
- func (i *VM) Entrypoints() map[string]int32
- func (i *VM) Eval(ctx context.Context, entrypoint int32, input *interface{}, ...) ([]byte, error)
- func (i *VM) Println(arg int32)
- func (i *VM) RemoveDataPath(ctx context.Context, path []string) error
- func (i *VM) SetDataPath(ctx context.Context, path []string, value interface{}) error
- func (i *VM) SetPolicyData(ctx context.Context, opts vmOpts) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool maintains a pool of WebAssemly VM instances.
func (*Pool) Acquire ¶
Acquire obtains a VM from the pool, waiting if all VMms are in use and building one as necessary. Returns either ErrNotReady or ErrInternal if an error.
func (*Pool) Close ¶
func (p *Pool) Close()
Close waits for all the evaluations to finish and then releases the VMs.
func (*Pool) ParsedData ¶
ParsedData returns a reference to the pools parsed external data used to initialize new VM's.
func (*Pool) RemoveDataPath ¶
RemoveDataPath will update the current data on the VMs by removing the value at the specified path. If an error occurs the instance is still in a valid state, however the data will not have been modified.
func (*Pool) SetDataPath ¶
SetDataPath will update the current data on the VMs by setting the value at the specified path. If an error occurs the instance is still in a valid state, however the data will not have been modified.
func (*Pool) SetPolicyData ¶
SetPolicyData re-initializes the vms within the pool with the new policy and data. The re-initialization takes place atomically: all new vms are constructed in advance before touching the pool. Returns either ErrNotReady, ErrInvalidPolicy or ErrInternal if an error occurs.
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM is a wrapper around a Wasm VM instance
func (*VM) Entrypoints ¶
Entrypoints returns a mapping of entrypoint name to ID for use by Eval().
func (*VM) Eval ¶
func (i *VM) Eval(ctx context.Context, entrypoint int32, input *interface{}, metrics metrics.Metrics, seed io.Reader, ns time.Time, iqbCache cache.InterQueryCache, ndbCache builtins.NDBCache, ph print.Hook, capabilities *ast.Capabilities) ([]byte, error)
Eval performs an evaluation of the specified entrypoint, with any provided input, and returns the resulting value dumped to a string.
func (*VM) RemoveDataPath ¶
RemoveDataPath will update the current data on the VM by removing the value at the specified path. If an error occurs the instance is still in a valid state, however the data will not have been modified.
func (*VM) SetDataPath ¶
SetDataPath will update the current data on the VM by setting the value at the specified path. If an error occurs the instance is still in a valid state, however the data will not have been modified.