-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Hi,
it's currently really hard to do async callbacks in wasm. I think wrpc is an almost perfect alternative. However it does not seem like wit can provide "server" functionality from client.
Suppose we would like to implement hello() in wasi using go and we need to fetch some data for internet. For this we could use the following interface
package wrpc-examples:hello;
interface callback {
use wrpc:rpc/error@0.1.0.{error};
fetch: func(url: string) -> result<list<u8>, error>;
}
interface handler {
hello: func() -> string;
}
world client {
import handler;
export callback;
}
world server {
export handler;
import callback;
}
So now node.js can export fetch(), call wasi "business logic that needs to fetch data from net" giving it a way to get to net. This could also be used to expose databases, etc.
sequenceDiagram
participant Client as Client (Node.js)
participant Server as Server (WASI)
Client->>Server: hello()
activate Server
Server->>Client: fetch(url)
activate Client
Client-->>Server: result<list<u8>, error>
deactivate Client
Server-->>Client: Processed result (string)
deactivate Server
Is this something that wrpc would support? It looks like currently code doesn't preclude such things.
Metadata
Metadata
Assignees
Labels
No labels