Class GrpcHealthRegistry
-
Method Summary
Modifier and TypeMethodDescriptionentries()Returns all non-default service to status entries plus the default status.static GrpcHealthRegistryGet the status for a service name, falling back to the default status when the name has no registered override.booleanisRegistered(String serviceName) Returns whether a health status has been registered for the given service name.voidremoveStatus(String serviceName) Remove the override for a specific service so it reverts to the default.voidreset()voidsetStatus(String serviceName, ServingStatus status) Set the status for a specific service name (empty string = default for all).
-
Method Details
-
getInstance
-
setStatus
Set the status for a specific service name (empty string = default for all). -
getStatus
Get the status for a service name, falling back to the default status when the name has no registered override.Callers must consult
isRegistered(java.lang.String)first. The fallback here is NOT the health-check contract for a named service:Checkon an unregistered service must fail withNOT_FOUNDrather than inherit the default, so calling this method alone would report an unknown service as healthy. The fallback remains because it is correct for the empty (overall-server) name, and because theGETcontrol-plane endpoint reports effective status. -
isRegistered
Returns whether a health status has been registered for the given service name.The empty service name is the overall-server health target defined by
grpc.health.v1.Health; it always has a status (the default) and so is always registered. A named service is registered only oncesetStatus(java.lang.String, org.mockserver.grpc.ServingStatus)has been called for it — the default status is deliberately NOT treated as covering arbitrary names, becauseCheckon an unregistered service must fail withNOT_FOUNDrather than inherit a status. Without this distinction a typo'd service name reports healthy. -
entries
Returns all non-default service to status entries plus the default status. -
removeStatus
Remove the override for a specific service so it reverts to the default. An empty service name resets the default status itself back to SERVING. -
reset
public void reset()
-