apa512 / clj-rethinkdb

Eclipse Public License 1.0
204 stars 42 forks source link

Make success sequence return each result as an element in the stream #161

Open danielcompton opened 8 years ago

danielcompton commented 8 years ago

In the official RethinkDB drivers, success sequence's return a single row in each element. This is a fairly natural model, and hides the fact that some results are returned in chunks. Currently, success sequence results are put onto the core.async channel as a single value. Would you be open to changing the model to match how the official drivers do it?

apa512 commented 8 years ago

Just to make sure I understand: do you mean that async operations (except for changefeeds) return a cursor (which can be used like a lazy seq) on the channel as opposed to one item at a time?

I considered the second option but decided against it because I couldn't find a convenient way to get all items from the channel, which is usually what I want.

danielcompton commented 8 years ago

Currently, if you get a stream back (either success sequence, or success partial), all of the rows in the stream are put as one 'item' on the core.async channel. I'm suggesting that each row is put on as a separate item on the channel.

Currently:

[    [  [row 1] [row 2] [row 3]  ]  [ [row 4] [row 5] [row 6] ]     ]

In the future:

[  [row 1] [row 2] [row 3] [row 4] [row 5] [row 6]  ]

You can use (core.async/into ch []) which returns a go block with the contents of chan in the vector, which I think is what you're after.

The failing tests that I've implemented demonstrate the behaviour I'm looking for.

lenaschoenburg commented 8 years ago

Are you still working on this?/Can I help in some way? The new behaviour would be immensely helpful for code that does not need to distinguish between changefeeds and sequences.

apa512 commented 8 years ago

I plan to implement this but I'm not sure how soon. Probably in a week or two.

lenaschoenburg commented 8 years ago

Great, thank you very much!

danielcompton commented 8 years ago

I also hope to get to it in a week or so :)