Skip to content

health check service #1821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2016
Merged

health check service #1821

merged 3 commits into from
May 20, 2016

Conversation

dapengzhang0
Copy link
Member

syntax = "proto3";

package grpc.health.v1;
option java_package = "io.grpc.services.health";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should have a grpc/common to put protos, and just submodule this.

I've talked to @ctiller about doing this and he seemed to be in agreement. Maybe we can try it out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carl-mastrangelo I am in favor of that.

@buchgr
Copy link
Contributor

buchgr commented May 13, 2016

@dapengzhang0 @zhangkun83

I assume the planned usage right now is:

HealthStatusManager manager = 
  new HealthStatusManager(HealthServiceFactory.newHealthService());

serverBuilder
  .addService(new MyService1(manager))
  .addService(new MyService2(manager))
  .build()
  .start();

Wondering if we should add i.e. ServerBuilder.healthStatusManager(...) and integrate this into the ServerServiceDefinition?

@dapengzhang0
Copy link
Member Author

dapengzhang0 commented May 13, 2016

@buchgr
Had a discussion with @zhangkun83 , we don't implement Health feature in ServiceBuilder and/or ServerServiceDefinition right now because we don't want to introduce dependency on protobuff into grpc-core project. (Health depends on protobuff)

import org.mockito.InOrder;

public class HealthStatusManagerTest {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I missed this:
/** Unit tests for {@link HealthStatusManager}. */
@RunWith(JUnit4.class)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dapengzhang0
Copy link
Member Author

PTAL

respond(status, responseObserver);
}

private void respond(ServingStatus status, StreamObserver<HealthCheckResponse> responseObserver) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually create private methods either for re-using a piece of logic, or breaking down a large method to improve readability. Neither is the case here. It's probably better to merge it with check().

@dapengzhang0
Copy link
Member Author

dapengzhang0 commented May 18, 2016

PTAL again
thx

@zhangkun83
Copy link
Contributor

LGTM


package grpc.health.v1;
option csharp_namespace = "Grpc.Health.V1";
option java_package = "io.grpc.services.health";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package name must include 'v1'. We should probably use io.grpc.health.v1 as the package name. Let me look for the doc that can shed some more light on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The googleapis has some examples. https://github.com/googleapis/googleapis/blob/master/google/bigtable/v1/bigtable_service_messages.proto

The version number is part of the name to allow future versions without colliding. We probably will want to specify java_multiple_files and java_outer_classname as well. The reason it isn't the default is due to backward compatibility. Note that these changes have to be done sooner than later since these names are exposed to the user as part of the API (since ServingStatus is used directly).

The common convention for java_outer_classname is to use FileNameProto. So in this case it would be HealthProto.


import static io.grpc.services.health.HealthOuterClass.HealthCheckResponse;
import static io.grpc.services.health.HealthOuterClass.HealthCheckResponse.ServingStatus;
import static io.grpc.health.v1.HealthCheckResponse.ServingStatus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this can be a normal (non-static import). Doesn't matter which way you do it though.

@ejona86
Copy link
Member

ejona86 commented May 20, 2016

@dapengzhang0 LGTM

StreamObserver<HealthCheckResponse> responseObserver) {
ServingStatus status = getStatus(request.getService());
if (status == null) {
responseObserver.onError(new StatusException(Status.NOT_FOUND));
Copy link

@asadali asadali Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dapengzhang0 i am a bit confused about the default behavior here

from the grpc health check doc:

A client can query the server’s health status by calling the Check method, and a deadline should be set on the rpc. The client can OPTIONALLY set the service name it wants to query for health status.

with the current implementation, the server expects a service name to be COMPULSORILY specified in the request and returns a Status.NOT_FOUND for an empty service check. shouldn't it respond with the general health of the server, which should be counted as SERVING independent of the included service's statuses.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm: the very next statement from the doc helped clarify it:

The server should register all the services manually and set the individual status, including an empty service name and its status.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants