-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Add List method to gRPC Health service #8155
base: master
Are you sure you want to change the base?
Conversation
This change introduces a new `List` RPC endpoint for the Health service, allowing clients to retrieve the statuses of all monitored services. This feature simplifies integration with status-reporting dashboards and enhances observability for microservices. Proposal: grpc/proposal#468 gRPC-proto change: grpc/grpc-proto#143 Signed-off-by: Marcos Huck <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I regenerated the Go stubs using the work in progress version of grpc/grpc-proto#143
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I regenerated the Go stubs using the work in progress version of grpc/grpc-proto#143
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8155 +/- ##
==========================================
- Coverage 82.32% 82.29% -0.04%
==========================================
Files 392 392
Lines 39140 39156 +16
==========================================
+ Hits 32222 32223 +1
- Misses 5597 5605 +8
- Partials 1321 1328 +7
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcoshuck i think we need to wait for the proposal and proto change to be merged before this? I still see them in review
@dfawley cc
s.mu.RLock() | ||
defer s.mu.RUnlock() | ||
|
||
if len(s.statusMap) > 100 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 100 can be a const above with a meaningful variable name
@@ -81,3 +86,46 @@ func (s) TestShutdown(t *testing.T) { | |||
t.Fatalf("status for %s is %v, want %v", testService, status, healthpb.HealthCheckResponse_NOT_SERVING) | |||
} | |||
} | |||
|
|||
func (s) TestList(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please docstring for Test explaining what is it verifying
s := NewServer() | ||
|
||
// Remove the zero value | ||
delete(s.statusMap, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: need to acquire lock for this?
delete(s.statusMap, "") | ||
|
||
// Fill out status map with service information, 101 elements will trigger an error. | ||
for i := 1; i <= 101; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to have separate test for ResourceExhausted and success
} | ||
|
||
for key := range out.GetStatuses() { | ||
if _, ok := s.statusMap[key]; !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should also verify the serving status?
} | ||
|
||
// Remove the 101 element to avoid the error. | ||
delete(s.statusMap, "101") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can have separate test for success, the we don't need to have list of 100 services. 2 would be enough
This change introduces a new
List
RPC endpoint for the Health service, allowing clients to retrieve the statuses of all monitored services. This feature simplifies integration with status-reporting dashboards and enhances observability for microservices.Proposal: grpc/proposal#468
gRPC-proto change: grpc/grpc-proto#143