couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodall <matt.good...@gmail.com>
Subject Re: feed=continuous and newline
Date Thu, 06 Aug 2009 15:55:05 GMT
2009/8/6 Brian Candler <B.Candler@pobox.com>:
> Raising a minor point here for discussion, rather than on JIRA.
>
> With feed=continuous, the newline after the last record isn't sent until the
> *next* record is available. For example:
>
> $ telnet localhost 5984
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> GET /test/_changes?feed=continuous HTTP/1.0
> Host: localhost
>
> HTTP/1.0 200 OK
> Server: CouchDB/0.10.0a (Erlang OTP/R12B)
> Date: Thu, 06 Aug 2009 14:11:26 GMT
> Content-Type: text/plain;charset=utf-8
> Cache-Control: must-revalidate
>
> {"results":[
> {"seq":1,"id":"1f9bcccaadf2c3e9508d42532838595f","changes":[{"rev":"1-23202479633c2b380f79507a776743d5"}]},
> {"seq":2,"id":"291e49cc084d2e180f3a5d313d255889","changes":[{"rev":"1-3975759ccff3842adf690a5c10caee42"}]},
> {"seq":3,"id":"a6bdc0e451df85169178f0d9619b605a","changes":[{"rev":"1-027467bd0efec85f21c822a8eb537073"}]}
>                 --------------------->
>                  stops at end of line
>
> When the next record is generated, it adds <comma> <newline> <record>.
>
> Whilst this makes the feed pretty to read, it doesn't make it easy to parse,
> as you basically need a full JSON stream parser to delimit the record. Or
> else, you're always one record behind.
>
> Wouldn't it be better to send the record followed by a newline, and then
> <comma> <record> <newline> for the next one? That is,
>
> {"results":[
> {"seq":1,"id":"1f9bcccaadf2c3e9508d42532838595f","changes":[{"rev":"1-23202479633c2b380f79507a776743d5"}]}
> ,{"seq":2,"id":"291e49cc084d2e180f3a5d313d255889","changes":[{"rev":"1-3975759ccff3842adf690a5c10caee42"}]}
> ,{"seq":3,"id":"a6bdc0e451df85169178f0d9619b605a","changes":[{"rev":"1-027467bd0efec85f21c822a8eb537073"}]}
> ],
> "last_seq":3}


Yep, I agree and already logged a ticket (with a patch) for this,
https://issues.apache.org/jira/browse/COUCHDB-405.

I'm actually sticking to using a longpoll feed for now to avoid the
messy parsing.

- Matt

Mime
View raw message