You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/02/13 19:12:41 UTC

[43/57] [abbrv] couchdb commit: updated refs/heads/1994-merge-rcouch-multi-repo to b19d055

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-multi-repo
Commit: ae6eae31a1f08b7116c3b47257fd34a01287427f
Parents: 81332b7
Author: Benoit Chesneau <bc...@gmail.com>
Authored: Thu Feb 13 16:37:35 2014 +0100
Committer: Benoit Chesneau <bc...@gmail.com>
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)}]}.