graphql-ruby icon indicating copy to clipboard operation
graphql-ruby copied to clipboard

Support Ably presence notifications

Open jscheid opened this issue 5 years ago • 0 comments

Is your feature request related to a problem? Please describe.

When using graphql-ruby-client with Ably, after a subscription terminates, it takes about a minute before the graphql-ruby server is notified.

This means that any triggers during that time period will cause unnecessary Ably messages to be sent, as well as potentially consumption of other resources (CPU, memory, database) depending on the subscription query.

Ably doesn't close the channel until after a delay:

channels are asynchronously gc'd about a minute after the last activity on the channel, see https://support.ably.io/en/support/solutions/articles/3000061294-how-does-ably-count-peak-channels-

Describe the solution you'd like

graphql-ruby should respond to Ably presence events instead of channel lifecycle events. I have verified that presence events are sent more or less immediately after the subscription has been disposed.

Describe alternatives you've considered

N/A

Additional context

~I've also verified that subscribing just to presence events isn't sufficient, as the leave event isn't fired if (for example) the browser tab running the app is simply closed.~

Ably pointed out that this is incorrect, not sure why I got the wrong reading:

If a connection disconnects abruptly, leave events should be fired for all of that connection's presence members 15s after the server notices that the connection has disconnected. In the worst case (tcp connection not closed properly) detecting that the connection is gone can take half a minute after the connection drops (detected using heartbeats). In the best/common case it should be immediate (closing the tab triggers the beforeunload handler which by default closes the connection).

jscheid avatar Jun 13 '20 04:06 jscheid