Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 213EF10231 for ; Sat, 15 Feb 2014 09:50:42 +0000 (UTC) Received: (qmail 41927 invoked by uid 500); 15 Feb 2014 09:49:27 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 41747 invoked by uid 500); 15 Feb 2014 09:49:19 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 41290 invoked by uid 99); 15 Feb 2014 09:49:10 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Feb 2014 09:49:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 27B5A927BAC; Sat, 15 Feb 2014 09:49:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: benoitc@apache.org To: commits@couchdb.apache.org Date: Sat, 15 Feb 2014 09:49:49 -0000 Message-Id: <5aae1568dbfa44898a36ad86975e52bd@git.apache.org> In-Reply-To: <462f90d1cb314bc68f38d5e7b324ddb6@git.apache.org> References: <462f90d1cb314bc68f38d5e7b324ddb6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [43/59] [abbrv] couchdb commit: updated refs/heads/1994-merge-rcouch to 6e59a78 remove couch_dbupdates Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ae6eae31 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ae6eae31 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ae6eae31 Branch: refs/heads/1994-merge-rcouch Commit: ae6eae31a1f08b7116c3b47257fd34a01287427f Parents: 81332b7 Author: Benoit Chesneau Authored: Thu Feb 13 16:37:35 2014 +0100 Committer: Benoit Chesneau Committed: Thu Feb 13 16:37:35 2014 +0100 ---------------------------------------------------------------------- .../couch_dbupdates/src/couch_dbupdates.app.src | 11 ---- apps/couch_dbupdates/src/couch_dbupdates.erl | 46 ------------- .../src/couch_dbupdates_httpd.erl | 69 -------------------- 3 files changed, 126 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae6eae31/apps/couch_dbupdates/src/couch_dbupdates.app.src ---------------------------------------------------------------------- diff --git a/apps/couch_dbupdates/src/couch_dbupdates.app.src b/apps/couch_dbupdates/src/couch_dbupdates.app.src deleted file mode 100644 index 54a543e..0000000 --- a/apps/couch_dbupdates/src/couch_dbupdates.app.src +++ /dev/null @@ -1,11 +0,0 @@ -{application, couch_dbupdates, - [ - {description, ""}, - {vsn, "1.0.0"}, - {registered, []}, - {applications, [ - kernel, - stdlib - ]}, - {env, []} - ]}. http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae6eae31/apps/couch_dbupdates/src/couch_dbupdates.erl ---------------------------------------------------------------------- diff --git a/apps/couch_dbupdates/src/couch_dbupdates.erl b/apps/couch_dbupdates/src/couch_dbupdates.erl deleted file mode 100644 index e37362f..0000000 --- a/apps/couch_dbupdates/src/couch_dbupdates.erl +++ /dev/null @@ -1,46 +0,0 @@ --module(couch_dbupdates). - --export([handle_dbupdates/3]). - - -handle_dbupdates(Fun, Acc, Options) -> - NotifierPid = db_update_notifier(), - try - loop(Fun, Acc, Options) - after - couch_db_update_notifier:stop(NotifierPid) - end. - - -loop(Fun, Acc, Options) -> - [{timeout, Timeout}, {heartbeat, Heartbeat}] = Options, - receive - {db_updated, Event} -> - case Fun(Event, Acc) of - {ok, Acc1} -> - loop(Fun, Acc1, Options); - stop -> - Fun(stop, Acc) - - end - after Timeout -> - case Heartbeat of - true -> - case Fun(heartbeat, Acc) of - {ok, Acc1} -> - loop(Fun, Acc1, Options); - stop -> - Fun(stop, Acc) - - end; - _ -> - Fun(stop, Acc) - end - end. - -db_update_notifier() -> - Self = self(), - {ok, Notifier} = couch_db_update_notifier:start_link(fun(Event) -> - Self ! {db_updated, Event} - end), - Notifier. http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae6eae31/apps/couch_dbupdates/src/couch_dbupdates_httpd.erl ---------------------------------------------------------------------- diff --git a/apps/couch_dbupdates/src/couch_dbupdates_httpd.erl b/apps/couch_dbupdates/src/couch_dbupdates_httpd.erl deleted file mode 100644 index 09f1104..0000000 --- a/apps/couch_dbupdates/src/couch_dbupdates_httpd.erl +++ /dev/null @@ -1,69 +0,0 @@ --module(couch_dbupdates_httpd). - --export([handle_req/1]). - --include_lib("couch/include/couch_db.hrl"). - --record(state, {resp, feed}). - -handle_req(#httpd{method='GET'}=Req) -> - ok = couch_httpd:verify_is_server_admin(Req), - Qs = couch_httpd:qs(Req), - Feed = proplists:get_value("feed", Qs, "longpoll"), - - Timeout = list_to_integer( - proplists:get_value("timeout", Qs, "60000") - ), - - Heartbeat0 = proplists:get_value("heartbeat", Qs), - Heartbeat = case {Feed, Heartbeat0} of - {"longpoll", _} -> false; - {_, "false"} -> false; - _ -> true - end, - - Options = [{timeout, Timeout}, {heartbeat, Heartbeat}], - - {ok, Resp} = case Feed of - "eventsource" -> - Headers = [ - {"Content-Type", "text/event-stream"}, - {"Cache-Control", "no-cache"} - ], - couch_httpd:start_json_response(Req, 200, Headers); - _ -> - couch_httpd:start_json_response(Req, 200) - end, - - State = #state{resp=Resp, feed=Feed}, - couch_dbupdates:handle_dbupdates(fun handle_update/2, - State, Options); - -handle_req(Req) -> - couch_httpd:send_method_not_allowed(Req, "GET"). - -handle_update(stop, #state{resp=Resp}) -> - couch_httpd:end_json_response(Resp); -handle_update(heartbeat, #state{resp=Resp}=State) -> - {ok, Resp1} = couch_httpd:send_chunk(Resp, "\n"), - {ok, State#state{resp=Resp1}}; -handle_update(Event, #state{resp=Resp, feed="eventsource"}=State) -> - EventObj = event_obj(Event), - {ok, Resp1} = couch_httpd:send_chunk(Resp, ["data: ", - ?JSON_ENCODE(EventObj), - "\n\n"]), - {ok, State#state{resp=Resp1}}; -handle_update(Event, #state{resp=Resp, feed="continuous"}=State) -> - EventObj = event_obj(Event), - {ok, Resp1} = couch_httpd:send_chunk(Resp, [?JSON_ENCODE(EventObj) | - "\n"]), - {ok, State#state{resp=Resp1}}; -handle_update(Event, #state{resp=Resp, feed="longpoll"}) -> - {Props} = event_obj(Event), - JsonObj = {[{<<"ok">>, true} | Props]}, - couch_httpd:send_chunk(Resp, ?JSON_ENCODE(JsonObj)), - stop. - -event_obj({Type, DbName}) -> - {[{<<"type">>, couch_util:to_binary(Type)}, - {<<"db_name">>, couch_util:to_binary(DbName)}]}.