You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ei...@apache.org on 2019/11/22 15:50:13 UTC

[couchdb] branch prototype/readiness-end-point updated (034eb33 -> fcbcee5)

This is an automated email from the ASF dual-hosted git repository.

eiri pushed a change to branch prototype/readiness-end-point
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 034eb33  Add new _ready end-point
     add be22ef9  Add operation names for all HTTP endpoints
     new fcbcee5  Add new _ready end-point

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (034eb33)
            \
             N -- N -- N   refs/heads/prototype/readiness-end-point (fcbcee5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/chttpd/src/chttpd.erl                          |   6 +-
 src/chttpd/src/chttpd_handlers.erl                 |  18 +-
 src/chttpd/src/chttpd_httpd_handlers.erl           | 454 ++++++++++++++++++++-
 .../src/global_changes_httpd_handlers.erl          |   8 +-
 src/mango/src/mango_httpd_handlers.erl             |  31 +-
 src/mem3/src/mem3_httpd_handlers.erl               |  38 +-
 src/setup/src/setup_httpd_handlers.erl             |  12 +-
 test/elixir/test/basics_test.exs                   |   6 +
 8 files changed, 546 insertions(+), 27 deletions(-)


[couchdb] 01/01: Add new _ready end-point

Posted by ei...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

eiri pushed a commit to branch prototype/readiness-end-point
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit fcbcee5e213565d6695d72bc8aa4c49dec6d09a8
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Mon Aug 26 16:54:38 2019 -0300

    Add new _ready end-point
    
    Add new _ready end-point similar to _up,
    but with a check for fdb availability.
---
 src/chttpd/src/chttpd_auth_request.erl   |  2 ++
 src/chttpd/src/chttpd_httpd_handlers.erl |  1 +
 src/chttpd/src/chttpd_misc.erl           | 14 ++++++++++++++
 test/elixir/test/basics_test.exs         |  6 ++++++
 4 files changed, 23 insertions(+)

diff --git a/src/chttpd/src/chttpd_auth_request.erl b/src/chttpd/src/chttpd_auth_request.erl
index 26fee17..d4ae060 100644
--- a/src/chttpd/src/chttpd_auth_request.erl
+++ b/src/chttpd/src/chttpd_auth_request.erl
@@ -84,6 +84,8 @@ authorize_request_int(#httpd{path_parts=[_DbName|_]}=Req) ->
 
 server_authorization_check(#httpd{path_parts=[<<"_up">>]}=Req) ->
     Req;
+server_authorization_check(#httpd{path_parts=[<<"_ready">>]}=Req) ->
+    Req;
 server_authorization_check(#httpd{path_parts=[<<"_uuids">>]}=Req) ->
     Req;
 server_authorization_check(#httpd{path_parts=[<<"_session">>]}=Req) ->
diff --git a/src/chttpd/src/chttpd_httpd_handlers.erl b/src/chttpd/src/chttpd_httpd_handlers.erl
index 7c657f5..c4b7f4c 100644
--- a/src/chttpd/src/chttpd_httpd_handlers.erl
+++ b/src/chttpd/src/chttpd_httpd_handlers.erl
@@ -30,6 +30,7 @@ url_handler(<<"_replicate">>)      -> fun chttpd_misc:handle_replicate_req/1;
 url_handler(<<"_uuids">>)          -> fun chttpd_misc:handle_uuids_req/1;
 url_handler(<<"_session">>)        -> fun chttpd_auth:handle_session_req/1;
 url_handler(<<"_up">>)             -> fun chttpd_misc:handle_up_req/1;
+url_handler(<<"_ready">>)          -> fun chttpd_misc:handle_ready_req/1;
 url_handler(_) -> no_match.
 
 db_handler(<<"_view_cleanup">>) -> fun chttpd_db:handle_view_cleanup_req/2;
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index 11d2c5b..57a15f0 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -23,6 +23,7 @@
     handle_system_req/1,
     handle_task_status_req/1,
     handle_up_req/1,
+    handle_ready_req/1,
     handle_utils_dir_req/1,
     handle_utils_dir_req/2,
     handle_uuids_req/1,
@@ -510,6 +511,19 @@ handle_up_req(#httpd{method='GET'} = Req) ->
 handle_up_req(Req) ->
     send_method_not_allowed(Req, "GET,HEAD").
 
+
+handle_ready_req(#httpd{method='GET'} = Req) ->
+    try
+        fabric2_db:list_dbs([{limit, 0}]),
+        send_json(Req, 200, {[{status, ready}]})
+    catch error:{timeout, _} ->
+        send_json(Req, 404, {[{status, unavailable}]})
+    end;
+
+handle_ready_req(Req) ->
+    send_method_not_allowed(Req, "GET,HEAD").
+
+
 message_queues(Registered) ->
     lists:map(fun(Name) ->
         Type = message_queue_len,
diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs
index dda2a0c..4e78ed3 100644
--- a/test/elixir/test/basics_test.exs
+++ b/test/elixir/test/basics_test.exs
@@ -18,6 +18,12 @@ defmodule BasicsTest do
     assert Couch.get("/").body["couchdb"] == "Welcome", "Should say welcome"
   end
 
+  test "Ready endpoint" do
+    resp = Couch.get("/_ready")
+    assert resp.status_code == 200
+    assert resp.body["status"] == "ready"
+  end
+
   @tag :with_db
   test "PUT on existing DB should return 412 instead of 500", context do
     db_name = context[:db_name]