Skip to content

services: implement Health.Watch#4930

Merged
zhangkun83 merged 3 commits into
grpc:masterfrom
zhangkun83:watch_based_healthcheck
Oct 12, 2018
Merged

services: implement Health.Watch#4930
zhangkun83 merged 3 commits into
grpc:masterfrom
zhangkun83:watch_based_healthcheck

Conversation

@zhangkun83

@zhangkun83 zhangkun83 commented Oct 10, 2018

Copy link
Copy Markdown
Contributor

Part of #4932

private final Object watchLock = new Object();

@GuardedBy("watchLock")
private final Multimap<String, StreamObserver<HealthCheckResponse>> watchers =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If possible I think it would be good if this was a Map<String, List>, to avoid guava deps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Although Guava collections dependency is permissible for server-side code, making Multimap use identity hash set would require extra code and lose the benefits of being shorter. I changed to the plain Java collections.

// Called when the client has closed the stream
public void cancelled(Context context) {
synchronized (watchLock) {
watchers.remove(service, responseObserver);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think there is promise about the equality of observers. An interceptor may pass in a StreamObserver that has equality based on call state.

I think the multimap values should be an identity hash set. That would make removal O(1), and avoid equality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

HashMultimap is O(1) removal, but the equality is a valid concern. Switch to identity hash set.

@carl-mastrangelo carl-mastrangelo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@zhangkun83 zhangkun83 merged commit 11f9e8d into grpc:master Oct 12, 2018
@zhangkun83 zhangkun83 deleted the watch_based_healthcheck branch October 16, 2018 01:02
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 14, 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.

2 participants