Class GrpcHealthRegistry

java.lang.Object
org.mockserver.grpc.GrpcHealthRegistry

public class GrpcHealthRegistry extends Object
  • Method Details

    • getInstance

      public static GrpcHealthRegistry getInstance()
    • setStatus

      public void setStatus(String serviceName, ServingStatus status)
      Set the status for a specific service name (empty string = default for all).
    • getStatus

      public ServingStatus getStatus(String serviceName)
      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: Check on an unregistered service must fail with NOT_FOUND rather 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 the GET control-plane endpoint reports effective status.

    • isRegistered

      public boolean isRegistered(String serviceName)
      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 once setStatus(java.lang.String, org.mockserver.grpc.ServingStatus) has been called for it — the default status is deliberately NOT treated as covering arbitrary names, because Check on an unregistered service must fail with NOT_FOUND rather than inherit a status. Without this distinction a typo'd service name reports healthy.

    • entries

      public Map<String,ServingStatus> entries()
      Returns all non-default service to status entries plus the default status.
    • removeStatus

      public void removeStatus(String serviceName)
      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()