iilyak commented on code in PR #5546:
URL: https://github.com/apache/couchdb/pull/5546#discussion_r2109704946
##########
src/dreyfus/src/clouseau_rpc.erl:
##########
@@ -316,3 +326,46 @@ rpc(Ref, Msg) ->
clouseau() ->
list_to_atom(config:get("dreyfus", "name", "[email protected]")).
+
+-type service() :: sup | main | analyzer | cleanup.
+-type liveness_status() :: alive | timeout.
+
+-spec clouseau_services(MajorVsn) -> [service()] when
+ MajorVsn :: binary() | null.
+clouseau_services(_MajorVsn) ->
+ [sup, main, analyzer, cleanup].
+
+-spec is_valid(Service) -> boolean() when
+ Service :: atom().
+is_valid(Service) when is_atom(Service) ->
+ lists:member(Service, clouseau_services(clouseau_major_vsn())).
+
+-spec check_service(Service) -> {service(), liveness_status()} | no_return()
when
+ Service :: service().
+check_service(Service) when is_list(Service) ->
+ check_service(list_to_atom(Service));
+check_service(Service) when is_atom(Service) ->
+ case is_valid(Service) of
+ true ->
+ Ref = make_ref(),
+ {Service, clouseau()} ! {ping, self(), Ref},
+ receive
+ {pong, Ref} ->
+ {Service, alive}
+ after ?TIMEOUT ->
+ {Service, timeout}
+ end;
+ false ->
+ NoService = atom_to_binary(Service),
+ throw({not_found, <<"no such service: ", NoService/binary>>})
+ end.
+
+-spec check_services() -> [{service(), liveness_status()}] | no_return().
Review Comment:
```
| throw(string())
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]