From dev-return-5601-apmail-couchdb-dev-archive=couchdb.apache.org@couchdb.apache.org Thu Aug 06 15:55:28 2009 Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 58100 invoked from network); 6 Aug 2009 15:55:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Aug 2009 15:55:28 -0000 Received: (qmail 69584 invoked by uid 500); 6 Aug 2009 15:55:35 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 69531 invoked by uid 500); 6 Aug 2009 15:55:35 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 69521 invoked by uid 99); 6 Aug 2009 15:55:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 15:55:35 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.9] (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 06 Aug 2009 15:55:32 +0000 Received: (qmail 57998 invoked by uid 99); 6 Aug 2009 15:55:02 -0000 Received: from localhost.apache.org (HELO [10.0.1.2]) (127.0.0.1) (smtp-auth username kocolosk, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2009 15:55:02 +0000 Message-Id: <284E5623-DCB8-4C8A-BDDB-5D7227BE3DAE@apache.org> From: Adam Kocoloski To: dev@couchdb.apache.org In-Reply-To: <20090806141741.GA11185@uk.tiscali.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Subject: Re: feed=continuous and newline Date: Thu, 6 Aug 2009 11:55:07 -0400 References: <20090806141741.GA11185@uk.tiscali.com> X-Mailer: Apple Mail (2.935.3) X-Virus-Checked: Checked by ClamAV on apache.org On Aug 6, 2009, at 10:17 AM, Brian Candler wrote: > 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 . > > 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 > 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} > > Regards, > > Brian. Hi Brian, Matt Goodall brought this up last month too: http://mail-archives.apache.org/mod_mbox/couchdb-dev/200907.mbox/%3c214c385b0907070612r3ed4dad9ydc9e81c7aa3f6e83@mail.gmail.com%3e I'm +1 on appending the newline immediately and moving the comma to the beginning of the next line. Adam