clj-rethinkdb icon indicating copy to clipboard operation
clj-rethinkdb copied to clipboard

Closing an async changefeed

Open danielcompton opened this issue 9 years ago • 10 comments
trafficstars

I'm looking at the new async code, and I'm not quite sure how to close a changefeed once I'm done with it. @apa512 do you have any ideas?

danielcompton avatar May 13 '16 11:05 danielcompton

I forgot to add this :cry:

Will fix soon. It's going to be closed when calling core.async/close!

apa512 avatar May 14 '16 10:05 apa512

Great, was thinking that would be a good way to do it.

danielcompton avatar May 14 '16 21:05 danielcompton

I'm not sure how to best communicate to the client that a channel has closed. Would it be enough to check if the channel is open when receiving a partial success, and close the feed if it's not?

This would leave the feed open if a change never happens after the channel is closed.

apa512 avatar May 16 '16 02:05 apa512

Do you mean that currently calling async/close! on a channel returned from clj-rethinkdb doesn't close the changefeed?

jwr avatar Jun 14 '16 08:06 jwr

Yes. The only way to close a changefeed is to close the connection.

apa512 avatar Jun 14 '16 11:06 apa512

Thanks. Very glad I caught this. This means I can't deploy into production what I've built, where new changefeeds are opened (and closed) regularly.

jwr avatar Jun 14 '16 11:06 jwr

Is there an example of a changefeed? I'd like to start using that with a core.async channel hooked with websocket. I know I know lazy programmer here, but I can add it to the README :smile:

arichiardi avatar Jul 04 '16 01:07 arichiardi

For anybody else who happens to end up here — the workaround is to maintain a separate connection for each changefeed, which you disconnect when the changefeed is no longer needed. This should work until you need lots of changefeeds.

jwr avatar Dec 18 '16 19:12 jwr

@apa512 Any movement on this? It requires pretty significant architectural workarounds for those of us managing lots of different changefeeds.

venantius avatar Apr 02 '17 01:04 venantius

I'm pretty sure this works in 1.0.0-SNAPSHOT. Let me get back to you with the specifics.

apa512 avatar Apr 03 '17 07:04 apa512