Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRpcRuntime ¶
func NewRpcRuntime[E any](srv Host[E], cfg wazero.RuntimeConfig) (runtime wazero.Runtime, ctx context.Context, err error)
NewRpcRuntime will instantiate a new wazero runtime with the given config. Additionally, the RPC Host and all its receivers will be exposed to all modules in this runtime.
IMPORTANT: Pass the returned context.Context (or a child context) to all runtime function calls. This context is required to link modules to the RPC Host.
Types ¶
type Host ¶
type Host[E any] struct { // contains filtered or unexported fields }
func (*Host[E]) RegisterMiddleware ¶
func (h *Host[E]) RegisterMiddleware(middleware Middleware)
RegisterMiddleware will add a preprocessing step to every client function call. Use this to handle permissions or provide context to downstream receivers. Only one Middleware can be registered and subsequent calls will override it.
type Middleware ¶
A Middleware can preprocess client function calls. Using the callers module name and called function a Middleware can return either an error or info.
- If an error is returned, no receivers will be executed and the error is retuned to the client.
- When no error is returned, the info is passed to the receiver invocation.
type Receiver ¶
type Receiver[E any] interface { // Binding returns a pointer to an allocated input and output type. // Later, wasmrpc will write parameters to the input type and read the result from the output type. Binding() (codecs.RpcArgs, codecs.RpcResp) // Execute is called by wasmrpc to handle calls to this Receiver. // For context, the user defined environment, the module name of the caller and the middleware info is passed to the Receiver. Execute(caller string, env E, info any) (err error) }
A Receiver exposes a function to clients.
Source Files
¶
- rpc.go
- runtime.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codecs implements available encoding formats used for client<->host communication.
|
Package codecs implements available encoding formats used for client<->host communication. |
|
Package msgprpc provides a static en-/decoder for requests and responses of the [MessagePack-RPC Specification](https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md).
|
Package msgprpc provides a static en-/decoder for requests and responses of the [MessagePack-RPC Specification](https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md). |
|
test
|
|
|
Package wasmguest is a go client implementation compatible with the wasmrpc main module.
|
Package wasmguest is a go client implementation compatible with the wasmrpc main module. |