couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodall <>
Subject _changes resource
Date Mon, 06 Jul 2009 12:50:45 GMT

Not sure if this is a user or dev message so posting to both.

I've started playing with the _changes resource to improve the
response time of some update processes that currently use
_all_docs_by_seq. cron is not exactly high resolution and a fast poll
is just not a nice thing to do.

== API ==

AFAICT, the _changes API supports four query params:

* since: non-inclusive seq num to start emitting changes from.
* continuous: boolean to enable "streaming" mode.
* heartbeat: period of inactivity (ms) after which a heartbeat newline
will be sent. continuous=true only.
* timeout: period of inactivity (ms) after which the end of the
document is sent and the connection closed. continuous=true only.

Did I find everything and are my descriptions correct? (I can feel a
wiki page coming on ;-))

== Response Document ==

The response looks something like this:

$ curl "http://localhost:5984/test/_changes"

Under what circumstances would 'changes' contain more than one item?
(Note: I couldn't see anything testing multiple 'changes').

Would it make sense to rename 'results' to 'rows' for just a little
consistency with a view's response?

Is last_seq at all useful?

== Line Breaks ==

If each results item is sent with its ending newline (the "," is sent
with the next item) it would make clients much easier and correct to
write, i.e. buffer bytes until a newline is received, split the
buffer, process the row, repeat. You've still got to remove the ","
from all but the first line but it's in a predictable place. Actually,
I don't believe TCP provides any guarantees that bytes sent are
received in the same chunks so relying on anything other than the
newline is probably flawed.

It's a trivial change, patch attached.

== Deleted and Conflicts==

_all_docs_by_seq includes a 'deleted' flag and a list of 'conflicts'.
Should the _changes API to do the same?

Hope that all makes sense.

- Matt

View raw message