Advice on Using Effect for WebSocket Subscriptions and RPC Connections
I'm looking at using Effect for serving requests over websockets. I have an Effect RPC server up and running serving requests over websockets, but now I need to set up subscriptions.
It seems that I can either
a) set up a new RPC endpoint that returns a Stream that never completes and send events by emitting to the Stream. This feels like it could be potential misuse of what RPC was initially intended for, and I've also discovered that it's necessary to send an Ack event back after each event received.
b) set up a separate websocket endpoint for these subscriptions. This gives me lower level control with access to the socket directly, rather than dealing with the abstraction of a stream, however, I believe, it also necessitates having each client manage two websocket connections: one for RPC and one for subscriptions, which is less than ideal.
Can anyone offer any suggestions / advice here? Is RPC for long lived connections misuse? Can I avoid having two client socket connections? (I know how I could do this with Express for example) Can I get access to the underling websocket from with my RPC handler?
Thank you
It seems that I can either
a) set up a new RPC endpoint that returns a Stream that never completes and send events by emitting to the Stream. This feels like it could be potential misuse of what RPC was initially intended for, and I've also discovered that it's necessary to send an Ack event back after each event received.
b) set up a separate websocket endpoint for these subscriptions. This gives me lower level control with access to the socket directly, rather than dealing with the abstraction of a stream, however, I believe, it also necessitates having each client manage two websocket connections: one for RPC and one for subscriptions, which is less than ideal.
Can anyone offer any suggestions / advice here? Is RPC for long lived connections misuse? Can I avoid having two client socket connections? (I know how I could do this with Express for example) Can I get access to the underling websocket from with my RPC handler?
Thank you
