-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streaming version of send #119
Comments
I agree, a streaming version would be very nice. I also think it would not be extremely hard to add. We would mainly need to patch |
i have a use-case where i need to just push the input from an IPC socket into an web socket, is this issue an deal breaker for this? It has to be somewhat performant (the workload for one connection is comparable to streaming video and it would have to handle multiple). I would guess just choosing smaller bytestrings could solve the problem. |
@LeanderK Yes, just splitting them up in multiple messages would do the trick. |
I was thinking about it, maybe if we put it in a new module with "Lazy" in the name :) |
The websockets library does not support streaming (jaspervdj/websockets#119). So, there is no value in superficially transforming data to a stream that later won't be streamed. However, WebSocketsData enables us to be polymorphic in the message type, i.e. let the endpoints type decide what to use. This would make streaming easier to enable (if it's ever implemented by the library) and safes us from some nasty conversion code.
The websockets library does not support streaming (jaspervdj/websockets#119). So, there is no value in superficially transforming data to a stream that later won't be streamed. However, WebSocketsData enables us to be polymorphic in the message type, i.e. let the endpoints type decide what to use. This would make streaming easier to enable (if it's ever implemented by the library) and safes us from some nasty conversion code.
* Single notification pushes are strict in their HTTP body The websockets library does not support streaming (jaspervdj/websockets#119). So, there is no value in superficially transforming data to a stream that later won't be streamed. However, WebSocketsData enables us to be polymorphic in the message type, i.e. let the endpoints type decide what to use. This would make streaming easier to enable (if it's ever implemented by the library) and safes us from some nasty conversion code. * Forward the pushed notification as is This reflects the prior behavior of Cannon (that should not change). The type RawJson represents json content as plain text.
It seems that the library doesn't have a streaming version for building websocket message. Here is the
send
code from the library:Since we can call
connectionWrite
only once when sending the message, it seems all of the data must be accumulated in memory to build the message. So, the lazy bytestring is not very useful because we must accumulate it all for the message.Is it trivial to build a streaming version of
send
on top ofWebsockets
library (basically, be able to callwrite
multiple times) ? Then, we could connect it withconduit
,pipes
orstreaming
.It seems
receive
is streaming because it has lazy bytestring. But,send
isn't despite lazy bytestring. Please correct me if I got this wrong.My use case is receiving and sending large objects through websocket server (an API server which is just an intermediary between the client and storage). I could do chunking through multiple messages, and then sending close code to indicate whether it is finished or not. But, it seems cleaner to build a single message in streaming fashion rather than building another streaming protocol on top of websocket messages.
The text was updated successfully, but these errors were encountered: