couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r805643 - in /couchdb/trunk/src/couchdb: couch_httpd_misc_handlers.erl couch_rep.erl
Date Wed, 19 Aug 2009 00:51:20 GMT
Author: kocolosk
Date: Wed Aug 19 00:51:19 2009
New Revision: 805643

URL: http://svn.apache.org/viewvc?rev=805643&view=rev
Log:
continuous replication request returns 202 Accepted and the _local docid

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
    couchdb/trunk/src/couchdb/couch_rep.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=805643&r1=805642&r2=805643&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Wed Aug 19 00:51:19 2009
@@ -80,6 +80,8 @@
 handle_replicate_req(#httpd{method='POST'}=Req) ->
     PostBody = couch_httpd:json_body_obj(Req),
     try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of
+    {ok, {continuous, RepId}} ->
+        send_json(Req, 202, {[{ok, true}, {<<"_local_id">>, RepId}]});
     {ok, {JsonResults}} ->
         send_json(Req, {[{ok, true} | JsonResults]});
     {error, {Type, Details}} ->

Modified: couchdb/trunk/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep.erl?rev=805643&r1=805642&r2=805643&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep.erl Wed Aug 19 00:51:19 2009
@@ -54,7 +54,7 @@
     replicate({[{<<"source">>, Source}, {<<"target">>, Target}]},
#user_ctx{});
 
 %% function handling POST to _replicate
-replicate(PostBody, UserCtx) ->
+replicate({Props}=PostBody, UserCtx) ->
     RepId = make_replication_id(PostBody, UserCtx),
     Replicator = {RepId,
         {gen_server, start_link, [?MODULE, [RepId, PostBody, UserCtx], []]},
@@ -66,6 +66,14 @@
 
     Server = start_replication_server(Replicator),
 
+    case proplists:get_value(<<"continuous">>, Props, false) of
+    true ->
+        {ok, {continuous, ?l2b(RepId)}};
+    false ->
+        get_result(Server, PostBody, UserCtx)
+    end.
+
+get_result(Server, PostBody, UserCtx) ->
     try gen_server:call(Server, get_result, infinity) of
     retry -> replicate(PostBody, UserCtx);
     Else -> Else



Mime
View raw message