summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_httpd_misc_handlers.erl2
-rw-r--r--src/couchdb/couch_rep.erl10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index e72f9d2f..c3c5b37a 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -80,6 +80,8 @@ handle_task_status_req(Req) ->
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}} ->
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index cde0a85e..592693ee 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -54,7 +54,7 @@ replicate(Source, Target) when is_binary(Source), is_binary(Target) ->
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 @@ replicate(PostBody, UserCtx) ->
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