livery_grpc_health_store (livery_grpc v0.1.0)
View SourceServing-status store behind livery_grpc_health, with watch subscriptions.
Holds the per-service status and the set of watchers. Setting a status
pushes a {grpc_health_watch, Service, Status} message to every watcher of
that service, which is how Watch streams live updates. Watchers are
monitored, so a disconnected watcher is dropped automatically.
The empty service name (<<>>) is the overall server status and defaults
to SERVING; a named service that was never set is unknown.
Summary
Functions
Set a service's serving status and notify its watchers.
The current status for Check: {ok, Status}, or not_found for a named
service that was never registered (the overall server defaults to
SERVING).
Register the caller as a watcher of Service and return the current
status to emit first. A named unknown service resolves to
SERVICE_UNKNOWN (Watch keeps the stream open rather than erroring).
Types
Functions
-spec code_change(term(), #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}, term()) -> {ok, #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}}.
-spec handle_call(term(), {pid(), term()}, #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}) -> {reply, term(), #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}}.
-spec handle_cast(term(), #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}) -> {noreply, #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}}.
-spec handle_info(term(), #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}) -> {noreply, #state{statuses :: #{binary() => serving_status()}, watchers :: #{binary() => #{pid() => reference()}}, monitors :: #{reference() => {binary(), pid()}}}}.
-spec set(binary(), serving_status()) -> ok.
Set a service's serving status and notify its watchers.
-spec status(binary()) -> {ok, serving_status()} | not_found.
The current status for Check: {ok, Status}, or not_found for a named
service that was never registered (the overall server defaults to
SERVING).
-spec subscribe(binary()) -> serving_status().
Register the caller as a watcher of Service and return the current
status to emit first. A named unknown service resolves to
SERVICE_UNKNOWN (Watch keeps the stream open rather than erroring).