Fork me on GitHub
#pedestal
<
2017-06-16
>
hlship20:06:21

Is there a general strategy for streaming intermittent data that's compatible with use of interceptors? I'm looking for the best way to handle GraphQL subscriptions, where we want to periodically put a blob of JSON into the response (probably driven by a core.async channel). But at the point where this executes, there's a couple of other interceptors on the stack that should be involved. Looking at http://pedestal.io/reference/streaming my best bet may be to return a callback function and stream the content, but them I'm duplicating a bunch of logic that (in the normal, non-subscription case) is inside a couple of interceptors .. .things like choosing a status code, and converting from Clojure data to JSON. Thoughts?

hlship20:06:15

The SSE code would be good, but is not compatible with GraphQL clients, which simply expect the stream of JSON blobs.

hlship20:06:39

And I also would like to know when the client closes the connection, so that we can do some cleanup.

hlship21:06:51

Digging deeper ... looks like web sockets are a valid approach for GraphQL subscriptions.

mpenet22:06:05

hlship: try to push for the open issue about ws to be fixed (reported in february). Atm it might allow 8 slow ws consumer or producer to exhaust/lock the async go threadpool (blocking IO in async/go blocks issues). Basically a potential DOS issue.

mpenet22:06:16

I checked back today and was surprised to see it s still open

mpenet22:06:05

hlship: try to push for the open issue about ws to be fixed (reported in february). Atm it might allow 8 slow ws consumer or producer to exhaust/lock the async go threadpool (blocking IO in async/go blocks issues). Basically a potential DOS issue.