You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2023/11/30 15:51:07 UTC

(couchdb) 01/02: Look up search node name in config for weatherreport

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

jan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7711c7389f6a9588277b776528e819ffe5c89f3a
Author: James Coglan <ja...@neighbourhood.ie>
AuthorDate: Thu Nov 30 10:35:47 2023 +0000

    Look up search node name in config for weatherreport
    
    Weatherreport is hard-coded to assume the search node is at
    'clouseau@127.0.0.1' and that it is running. This results in a useless
    warning for users that do not have search enabled, and also means that
    it will fail to connect if Clouseau is running somewhere other than
    127.0.0.1.
    
    This replaces the hard-coded node name with a config lookup to
    `[dreyfus] name` and handles the case of it not being set.
---
 .../src/weatherreport_check_search.erl             | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/weatherreport/src/weatherreport_check_search.erl b/src/weatherreport/src/weatherreport_check_search.erl
index b7986db2b..39ec3ca63 100644
--- a/src/weatherreport/src/weatherreport_check_search.erl
+++ b/src/weatherreport/src/weatherreport_check_search.erl
@@ -44,16 +44,24 @@ valid() ->
 
 -spec check(list()) -> [{atom(), term()}].
 check(_Opts) ->
-    SearchNode = 'clouseau@127.0.0.1',
-    case net_adm:ping(SearchNode) of
-        pong ->
-            [{info, {clouseau_ok, SearchNode}}];
-        Error ->
-            % only warning since search is not enabled by default
-            [{warning, {clouseau_error, SearchNode, Error}}]
+    SearchNodeStr = config:get("dreyfus", "name"),
+    case SearchNodeStr of
+        undefined ->
+            [{info, clouseau_not_configured}];
+        _ ->
+            SearchNode = list_to_atom(SearchNodeStr),
+            case net_adm:ping(SearchNode) of
+                pong ->
+                    [{info, {clouseau_ok, SearchNode}}];
+                Error ->
+                    % only warning since search is not enabled by default
+                    [{warning, {clouseau_error, SearchNode, Error}}]
+            end
     end.
 
 -spec format(term()) -> {io:format(), [term()]}.
+format(clouseau_not_configured) ->
+    {"Clouseau service is not configured", []};
 format({clouseau_ok, SearchNode}) ->
     {"Local search node at ~w responding ok", [SearchNode]};
 format({clouseau_error, SearchNode, Error}) ->