You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/01 11:06:04 UTC
[28/49] chttpd commit: updated refs/heads/windsor-merge to 554ef74
Report pending count in _changes
BugzID: 24236
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/c14123fd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/c14123fd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/c14123fd
Branch: refs/heads/windsor-merge
Commit: c14123fdc6ff6ce0c69db6339160ad7c1c9cc6f0
Parents: 5dc3640
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Thu Oct 17 14:36:11 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 30 11:17:38 2014 +0100
----------------------------------------------------------------------
src/chttpd_db.erl | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/c14123fd/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index a6c6594..b2b766b 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -88,9 +88,15 @@ changes_callback({change, Change}, {"continuous", Resp}) ->
{ok, Resp1} = chttpd:send_delayed_chunk(Resp, [?JSON_ENCODE(Change) | "\n"]),
{ok, {"continuous", Resp1}};
changes_callback({stop, EndSeq0}, {"continuous", Resp}) ->
+ % Temporary upgrade clause - Case 24236
+ changes_callback({stop, EndSeq0, null}, {"continuous", Resp});
+changes_callback({stop, EndSeq0, Pending}, {"continuous", Resp}) ->
EndSeq = case is_old_couch(Resp) of true -> 0; false -> EndSeq0 end,
- {ok, Resp1} = chttpd:send_delayed_chunk(Resp,
- [?JSON_ENCODE({[{<<"last_seq">>, EndSeq}]}) | "\n"]),
+ Row = {[
+ {<<"last_seq">>, EndSeq},
+ {<<"pending">>, Pending}
+ ]},
+ {ok, Resp1} = chttpd:send_delayed_chunk(Resp, [?JSON_ENCODE(Row) | "\n"]),
chttpd:end_delayed_json_response(Resp1);
% callbacks for eventsource feed (newline-delimited eventsource Objects)
@@ -130,13 +136,21 @@ changes_callback(start, {_, Req}) ->
changes_callback({change, Change}, {Prepend, Resp}) ->
{ok, Resp1} = chttpd:send_delayed_chunk(Resp, [Prepend, ?JSON_ENCODE(Change)]),
{ok, {",\r\n", Resp1}};
-changes_callback({stop, EndSeq}, {_, Resp}) ->
+changes_callback({stop, EndSeq}, Acc) ->
+ % Temporary upgrade clause - Case 24236
+ changes_callback({stop, EndSeq, null}, Acc);
+changes_callback({stop, EndSeq, Pending}, {_, Resp}) ->
{ok, Resp1} = case is_old_couch(Resp) of
true ->
chttpd:send_delayed_chunk(Resp, "\n],\n\"last_seq\":0}\n");
false ->
- chttpd:send_delayed_chunk(Resp,
- ["\n],\n\"last_seq\":", ?JSON_ENCODE(EndSeq), "}\n"])
+ chttpd:send_delayed_chunk(Resp, [
+ "\n],\n\"last_seq\":",
+ ?JSON_ENCODE(EndSeq),
+ ",\"pending\":",
+ ?JSON_ENCODE(Pending),
+ "}\n"
+ ])
end,
chttpd:end_delayed_json_response(Resp1);