couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject couch-mrview commit: updated refs/heads/1993-bigcouch-couch-mrview to 25fb687
Date Tue, 25 Mar 2014 23:39:00 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/1993-bigcouch-couch-mrview f407a9e0f -> 25fb6879c


Expose list_cb and provide json_req_obj indirection

This exposes the list_cb function for external use, specifically for
chttpd_show. This also adds an indirection layer for fetching
json_req_obj so that we can use list_cb for views that are local as
well as those not on the current node.


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

Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: 25fb6879c808d6f5b0cf2b02a6b8693919c63433
Parents: f407a9e
Author: Russell Branca <chewbranca@gmail.com>
Authored: Tue Mar 25 16:05:11 2014 -0700
Committer: Russell Branca <chewbranca@gmail.com>
Committed: Tue Mar 25 16:05:11 2014 -0700

----------------------------------------------------------------------
 src/couch_mrview_show.erl | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/25fb6879/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_show.erl b/src/couch_mrview_show.erl
index 0b42da5..6937467 100644
--- a/src/couch_mrview_show.erl
+++ b/src/couch_mrview_show.erl
@@ -15,7 +15,8 @@
 -export([
     handle_doc_show_req/3,
     handle_doc_update_req/3,
-    handle_view_list_req/3
+    handle_view_list_req/3,
+    list_cb/2
 ]).
 
 -include_lib("couch/include/couch_db.hrl").
@@ -251,7 +252,7 @@ list_cb(complete, Acc) ->
 
 start_list_resp(Head, Acc) ->
     #lacc{db=Db, req=Req, qserver=QServer, lname=LName} = Acc,
-    JsonReq = couch_httpd_external:json_req_obj(Req, Db),
+    JsonReq = json_req_obj(Req, Db),
 
     [<<"start">>,Chunk,JsonResp] = couch_query_servers:ddoc_proc_prompt(QServer,
         [<<"lists">>, LName], [Head, JsonReq]),
@@ -361,3 +362,13 @@ json_apply_field({Key, NewValue}, [], Acc) ->
     % end of list, add ours
     {[{Key, NewValue}|Acc]}.
 
+
+% This loads the db info if we have a fully loaded db record, but we might not
+% have the db locally on this node, so then load the info through fabric.
+json_req_obj(Req, #db{main_pid=Pid}=Db) when is_pid(Pid) ->
+    couch_httpd_external:json_req_obj(Req, Db);
+json_req_obj(Req, Db) ->
+    % use a separate process because we're already in a receive loop, and
+    % json_req_obj calls fabric:get_db_info()
+    spawn_monitor(fun() -> exit(chttpd_external:json_req_obj(Req, Db)) end),
+    receive {'DOWN', _, _, _, JsonReq} -> JsonReq end.


Mime
View raw message