You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/01/25 14:10:49 UTC

[couchdb] branch 503-if-search-not-available created (now b2cdabf20)

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

rnewson pushed a change to branch 503-if-search-not-available
in repository https://gitbox.apache.org/repos/asf/couchdb.git


      at b2cdabf20 return 503 immediately if search is not available

This branch includes the following new commits:

     new f19f33e4b Exclude asdf's config file
     new b2cdabf20 return 503 immediately if search is not available

The 2 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.



[couchdb] 02/02: return 503 immediately if search is not available

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

rnewson pushed a commit to branch 503-if-search-not-available
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit b2cdabf2099fbd20e5ce32366aa1733e0c64155e
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Jan 25 14:02:47 2023 +0000

    return 503 immediately if search is not available
---
 src/dreyfus/src/dreyfus_httpd.erl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/dreyfus/src/dreyfus_httpd.erl b/src/dreyfus/src/dreyfus_httpd.erl
index 39d205b95..f6607d644 100644
--- a/src/dreyfus/src/dreyfus_httpd.erl
+++ b/src/dreyfus/src/dreyfus_httpd.erl
@@ -42,6 +42,7 @@ handle_search_req(
 ) when
     Method == 'GET'; Method == 'POST'
 ->
+    verify_search_available(),
     DbName = couch_db:name(Db),
     Start = os:timestamp(),
     QueryArgs =
@@ -140,6 +141,7 @@ handle_info_req(
     Db,
     #doc{id = Id} = DDoc
 ) ->
+    verify_search_available(),
     DbName = couch_db:name(Db),
     case dreyfus_fabric_info:go(DbName, DDoc, IndexName, info) of
         {ok, IndexInfoList} ->
@@ -162,6 +164,7 @@ handle_info_req(Req, _Db, _DDoc) ->
 handle_disk_size_req(
     #httpd{method = 'GET', path_parts = [_, _, _, _, IndexName]} = Req, Db, #doc{id = Id} = DDoc
 ) ->
+    verify_search_available(),
     DbName = couch_db:name(Db),
     case dreyfus_fabric_info:go(DbName, DDoc, IndexName, disk_size) of
         {ok, IndexInfoList} ->
@@ -188,10 +191,12 @@ handle_cleanup_req(Req, _Db) ->
     send_method_not_allowed(Req, "POST").
 
 handle_analyze_req(#httpd{method = 'GET'} = Req) ->
+    verify_search_available(),
     Analyzer = couch_httpd:qs_value(Req, "analyzer"),
     Text = couch_httpd:qs_value(Req, "text"),
     analyze(Req, Analyzer, Text);
 handle_analyze_req(#httpd{method = 'POST'} = Req) ->
+    verify_search_available(),
     couch_httpd:validate_ctype(Req, "application/json"),
     {Fields} = chttpd:json_body_obj(Req),
     Analyzer = couch_util:get_value(<<"analyzer">>, Fields),
@@ -707,3 +712,11 @@ backoff_and_retry(Req, Db, DDoc, RetryCount, RetryPause, Error) ->
             timer:sleep(RetryPause),
             handle_search_req(Req, Db, DDoc, RetryCount + 1, RetryPause * 2)
     end.
+
+verify_search_available() ->
+    case dreyfus:available() of
+        true ->
+            ok;
+        false ->
+            throw({service_unavailable, <<"Search is not available">>})
+    end.


[couchdb] 01/02: Exclude asdf's config file

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

rnewson pushed a commit to branch 503-if-search-not-available
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f19f33e4be0c0def222e39113161d7883474c39a
Author: Robert Newson <rn...@apache.org>
AuthorDate: Thu Jan 5 11:46:13 2023 +0000

    Exclude asdf's config file
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 95c05e981..a65b4327d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -133,3 +133,5 @@ test/javascript/junit.xml
 
 .idea
 *.lock
+
+.tool-versions