Documentation ¶
Index ¶
- type CommonBuffer
- type CommonHeader
- func (h CommonHeader) Add(key string, value string)
- func (h CommonHeader) ByteSize() uint64
- func (h CommonHeader) Clone() HeaderMap
- func (h CommonHeader) Del(key string)
- func (h CommonHeader) Get(key string) (value string, ok bool)
- func (h CommonHeader) Range(f func(key, value string) bool)
- func (h CommonHeader) Set(key string, value string)
- type HeaderMap
- type IoBuffer
- type WasmFunction
- type WasmInstance
- type WasmModule
- type WasmVM
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonBuffer ¶
type CommonBuffer struct {
// contains filtered or unexported fields
}
CommonBuffer is a simple implementation of IoBuffer.
func (*CommonBuffer) Bytes ¶
func (c *CommonBuffer) Bytes() []byte
func (*CommonBuffer) Drain ¶
func (c *CommonBuffer) Drain(offset int)
func (*CommonBuffer) Len ¶
func (c *CommonBuffer) Len() int
type CommonHeader ¶
CommonHeader is a simple implementation of HeaderMap.
func (CommonHeader) Add ¶
func (h CommonHeader) Add(key string, value string)
func (CommonHeader) ByteSize ¶
func (h CommonHeader) ByteSize() uint64
func (CommonHeader) Clone ¶
func (h CommonHeader) Clone() HeaderMap
func (CommonHeader) Del ¶
func (h CommonHeader) Del(key string)
func (CommonHeader) Range ¶
func (h CommonHeader) Range(f func(key, value string) bool)
func (CommonHeader) Set ¶
func (h CommonHeader) Set(key string, value string)
type HeaderMap ¶
type HeaderMap interface { // Get value of key // If multiple values associated with this key, first one will be returned. Get(key string) (string, bool) // Set key-value pair in header map, the previous pair will be replaced if exists Set(key, value string) // Add value for given key. // Multiple headers with the same key may be added with this function. // Use Set for setting a single header for the given key. Add(key, value string) // Del delete pair of specified key Del(key string) // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. Range(f func(key, value string) bool) // Clone used to deep copy header's map Clone() HeaderMap // ByteSize return size of HeaderMap ByteSize() uint64 }
HeaderMap is a interface to provide operation facade with user-value headers.
type IoBuffer ¶
type IoBuffer interface { // Len returns the number of bytes of the unread portion of the buffer; // b.Len() == len(b.Bytes()). Len() int // Bytes returns all bytes from buffer, without draining any buffered data. // It can be used to get fixed-length content, such as headers, body. // Note: do not change content in return bytes, use write instead Bytes() []byte // Write appends the contents of p to the buffer, growing the buffer as // needed. The return value n is the length of p; err is always nil. If the // buffer becomes too large, Write will panic with ErrTooLarge. Write(p []byte) (n int, err error) // Drain drains a offset length of bytes in buffer. // It can be used with Bytes(), after consuming a fixed-length of data Drain(offset int) }
func NewIoBufferBytes ¶
type WasmFunction ¶
type WasmFunction interface { // Call invokes the wasm func Call(args ...interface{}) (interface{}, error) }
WasmFunction is the func exported by wasm module
type WasmInstance ¶
type WasmInstance interface { // Start starts the wasm instance Start() error // Stop stops the wasm instance Stop() // RegisterFunc registers a func to the wasm instance, should be called before Start() RegisterFunc(namespace string, funcName string, f interface{}) error // GetExportsFunc returns the exported func of the wasm instance GetExportsFunc(funcName string) (WasmFunction, error) // GetExportsMem returns the exported mem of the wasm instance GetExportsMem(memName string) ([]byte, error) // GetMemory returns wasm mem bytes from specified addr and size GetMemory(addr uint64, size uint64) ([]byte, error) // PutMemory sets wasm mem bytes to specified addr and size PutMemory(addr uint64, size uint64, content []byte) error // GetByte returns one wasm byte from specified addr GetByte(addr uint64) (byte, error) // PutByte sets one wasms bytes to specified addr PutByte(addr uint64, b byte) error // GetUint32 returns uint32 from specified addr GetUint32(addr uint64) (uint32, error) // PutUint32 set uint32 to specified addr PutUint32(addr uint64, value uint32) error // Malloc allocates size of mem from wasm default memory Malloc(size int32) (uint64, error) // GetData returns user-defined data GetData() interface{} // SetData sets user-defined data into the wasm instance SetData(data interface{}) // Acquire increases the ref count of the wasm instance Acquire() bool // Release decreases the ref count of the wasm instance Release() // Lock gets the exclusive ownership of the wasm instance // and sets the user-defined data Lock(data interface{}) // Unlock releases the exclusive ownership of the wasm instance // and sets the users-defined data to nil Unlock() // GetModule returns the wasm module of current instance GetModule() WasmModule // HandlerError processes the encountered err HandleError(err error) }
WasmInstance represents the wasm instance
type WasmModule ¶
type WasmModule interface { // Init got called when creating a new wasm module Init() // NewInstance instantiates and returns a new wasm instance NewInstance() WasmInstance // GetABINameList returns the abi name list exported by wasm module GetABINameList() []string }
WasmModule represents the wasm module
type WasmVM ¶
type WasmVM interface { // Name returns the name of wasm vm(engine) Name() string // Init got called when creating a new wasm vm(engine) Init() // NewModule compiles the 'wasmBytes' into a wasm module NewModule(wasmBytes []byte) WasmModule }
WasmVM represents the wasm vm(engine)
Click to show internal directories.
Click to hide internal directories.