Effect CommunityEC
Effect Community9mo ago
5 replies
tobi88

Comparing `Router.toHandlerEffect` to the New RPC Implementation in Effect Typescript

Is there anything comparable to Router.toHandlerEffect in the new RPC implementation? I'd like to evaluate RPC requests just by passing the payload. I guess the point is that the platform this runs on handles the data transfer. It passes me the raw payload and expects the response payload back.
Similarly, on the client side, I used something like Resolver.toClient(Resolver.makeEffect((requests) => Effect.promise(() => platformProvidedCallToServer(requests))()) where I pass the RPC payload and expect the RPC response back.
I have been studying the RpcServer source, and it looks like I may need to implement a custom protocol. Am I going the right way with this, or am I overcomplicating things?

My call used to look something like this:
const routerResponse = yield* Router.toHandlerEffect(userRouter)(request.payload);

where request is of type (not a HTTP request):
interface Request {
    payload: unknown;
    context: PlatfromInvokeContext;
}
Was this page helpful?