Package org.mockserver.grpc
Class GrpcHealthCheckHandler
java.lang.Object
org.mockserver.grpc.GrpcHealthCheckHandler
Handles grpc.health.v1.Health/Check requests without a proto descriptor.
Decodes the HealthCheckRequest manually (field 1 = service string),
looks up the ServingStatus from GrpcHealthRegistry, and encodes the
HealthCheckResponse manually (field 1 = status enum varint).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodeServiceName(byte[] grpcFramedBody) Decodes a HealthCheckRequest from gRPC-framed bytes and returns the service name.byte[]encodeResponse(ServingStatus status) Encodes a HealthCheckResponse as gRPC-framed bytes.Returns the ServingStatus for the given service name from this handler's registry.booleanisHealthCheckRequest(String path) Returns true if the request path matches the health check path.booleanisRegistered(String serviceName) Returns whetherCheckfor this service name should succeed at all.
-
Field Details
-
HEALTH_CHECK_PATH
- See Also:
-
-
Constructor Details
-
GrpcHealthCheckHandler
-
-
Method Details
-
isHealthCheckRequest
Returns true if the request path matches the health check path. -
getStatus
Returns the ServingStatus for the given service name from this handler's registry. Delegates to the registry so tests using a non-singleton registry get correct results. -
isRegistered
Returns whetherCheckfor this service name should succeed at all.grpc.health.v1.Health/Checkis specified to fail the RPC with statusNOT_FOUNDwhen the client asks about a service the server does not know about, rather than returning aHealthCheckResponse. Callers must consult this beforegetStatus(java.lang.String)and, when it returns false, respond with aNOT_FOUNDstatus and no message body. -
decodeServiceName
Decodes a HealthCheckRequest from gRPC-framed bytes and returns the service name. Returns empty string if the body is null/empty or cannot be decoded. -
encodeResponse
Encodes a HealthCheckResponse as gRPC-framed bytes. HealthCheckResponse { ServingStatus status = 1; }
-