apa512 / clj-rethinkdb

Eclipse Public License 1.0
205 stars 42 forks source link

Closing an async changefeed #160

Open danielcompton opened 8 years ago

danielcompton commented 8 years ago

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?

apa512 commented 8 years ago

I forgot to add this :cry:

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

danielcompton commented 8 years ago

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

apa512 commented 8 years ago

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.

jwr commented 8 years ago

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

apa512 commented 8 years ago

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

jwr commented 8 years ago

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.

arichiardi commented 8 years ago

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:

jwr commented 7 years ago

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.

venantius commented 7 years ago

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

apa512 commented 7 years ago

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