couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject git commit: Handle ddoc_updated event correctly.
Date Wed, 04 Jul 2012 09:52:11 GMT
Updated Branches:
  refs/heads/1.2.x 5f93f0414 -> bce1e60dc


Handle ddoc_updated event correctly.

COUCHDB-1309 introduced a new update event of the form {ddoc_updated,
{DbName, DDocId}}. Unfortunately it did not update
couch_db_update_notifier with a clause that can marshal this to JSON
successfully, breaking all uses of [update_notification]

This commit improves event encoding so that the above renders as
{"type":"ddoc_updated","db":"DbName","id":"DDocId"}

COUCHDB-1508


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/bce1e60d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bce1e60d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bce1e60d

Branch: refs/heads/1.2.x
Commit: bce1e60dcf31141f18b55e311709777b70f9a7f9
Parents: 5f93f04
Author: Robert Newson <rnewson@apache.org>
Authored: Wed Jul 4 10:32:19 2012 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 4 10:47:36 2012 +0100

----------------------------------------------------------------------
 src/couchdb/couch_db_update_notifier.erl |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/bce1e60d/src/couchdb/couch_db_update_notifier.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_db_update_notifier.erl b/src/couchdb/couch_db_update_notifier.erl
index 150eb31..bfa770a 100644
--- a/src/couchdb/couch_db_update_notifier.erl
+++ b/src/couchdb/couch_db_update_notifier.erl
@@ -53,8 +53,8 @@ handle_event(Event, Fun) when is_function(Fun, 1) ->
 handle_event(Event, {Fun, FunAcc}) ->
     FunAcc2 = Fun(Event, FunAcc),
     {ok, {Fun, FunAcc2}};
-handle_event({EventAtom, DbName}, Pid) ->
-    Obj = {[{type, list_to_binary(atom_to_list(EventAtom))}, {db, DbName}]},
+handle_event({EventType, EventDesc}, Pid) ->
+    Obj = encode_event(EventType, EventDesc),
     ok = couch_os_process:send(Pid, Obj),
     {ok, Pid}.
 
@@ -71,3 +71,12 @@ handle_info({'EXIT', _, _}, Pid) ->
 
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
+
+encode_event(EventType, EventDesc) when is_atom(EventType) ->
+    encode_event(atom_to_list(EventType), EventDesc);
+encode_event(EventType, EventDesc) when is_list(EventType) ->
+    encode_event(?l2b(EventType), EventDesc);
+encode_event(EventType, {DbName, DocId}) ->
+    {[{type, EventType}, {db, DbName}, {id, DocId}]};
+encode_event(EventType, DbName) ->
+    {[{type, EventType}, {db, DbName}]}.


Mime
View raw message