benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 114 forks source link

candidate for async save_doc #113

Open mcqueenorama opened 10 years ago

mcqueenorama commented 10 years ago

Can you have a look at my repo? In particular see examples/async_stream_to_save.erl and examples/async_save_inline.erl.

I don't want to make a pull request for it since its a bit experimental. It exposes the hackney async function to save_doc. I bet there's a better way to do it, but I couldn't figure it out. There's one small change needed in couchbeam_uuids, and the atom async didn't seem to work, but {async, true} does. I had to force the call to get_new_uuids is forced to go syncronously, but that's only rarely used, so its probably OK.

Also it uses hackney_disp.

benoitc commented 10 years ago

Sorry for the late answer, but what would be the purpose? Not waiting for the result but still beeing able to check if it arrived?

In that case I would prefer an api like this one: save_doc(..., [{async, AsyncOption}]) With the possibility to wait for a result in a pid or just ignore it totally. The result would be just {DocId, Result}) Eventually we could add some metadata.

Thoughts?

benoitc commented 9 years ago

ping.