livery_grpc_health (livery_grpc v0.1.0)

View Source

The standard grpc.health.v1.Health service, ready to mount.

Register it on a server with service/0:

livery_grpc:start_server(#{
    port     => 50051,
    services => [my_service_spec, livery_grpc_health:service()]
}).

Serving status is held per service name (the empty name <<>> is the overall server status, which defaults to SERVING). Set it with set_serving/0,1 and set_not_serving/0,1. Check returns the current status, or a not_found gRPC error for a named service that was never registered. Watch streams the current status and then a new message every time it changes, until the client disconnects.

Status and watch subscriptions live in livery_grpc_health_store, a gen_server started with the application.

Summary

Functions

Unary Check: the current serving status, or a not_found error.

The service spec to pass in a server's services list.

Mark the overall server as not serving.

Mark a named service as not serving.

Mark the overall server as serving.

Mark a named service as serving.

The current status for a service name. The overall server (<<>>) defaults to SERVING; a never-registered named service is SERVICE_UNKNOWN.

Server-streaming Watch: emit the current status, then a new message on every change, until the client disconnects.

Types

serving_status()

-type serving_status() :: livery_grpc_health_store:serving_status().

Functions

check(Request, Ctx)

-spec check(map(), livery_grpc_server:ctx()) ->
               {ok, map()} | {error, {livery_grpc_status:status(), binary()}}.

Unary Check: the current serving status, or a not_found error.

service()

-spec service() -> livery_grpc_service:registration().

The service spec to pass in a server's services list.

set_not_serving()

-spec set_not_serving() -> ok.

Mark the overall server as not serving.

set_not_serving(Service)

-spec set_not_serving(binary()) -> ok.

Mark a named service as not serving.

set_serving()

-spec set_serving() -> ok.

Mark the overall server as serving.

set_serving(Service)

-spec set_serving(binary()) -> ok.

Mark a named service as serving.

status(Service)

-spec status(binary()) -> serving_status().

The current status for a service name. The overall server (<<>>) defaults to SERVING; a never-registered named service is SERVICE_UNKNOWN.

watch(Request, Send, Ctx)

-spec watch(map(), fun((map()) -> ok | {error, term()}), livery_grpc_server:ctx()) -> ok.

Server-streaming Watch: emit the current status, then a new message on every change, until the client disconnects.