Skip to content

Conversation

@yigityazicilar
Copy link
Contributor

Motivation:
With gRFC A90 a List endpoint was added to the health service.

Modifications:

  • Update the health.proto file to the new version
  • Update the generated files using protoc
  • Add the new List endpoint to the HealthService
  • Add testing for the list endpoint

Result:
HealthService is now fully compliant with gRFC A90.

Motivation:
With gRFC A90 a `List` endpoint was added to the health service.

Modifications:
* Update the health.proto file to the new version
* Update the generated files using protoc
* Add the new `List` endpoint to the HealthService
* Add testing for the list endpoint

Result:
HealthService is now fully compliant with gRFC A90.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Thanks @yigityazicilar -- I left some feedback on the tests.

A note for next time: when you're dealing with vendored in and/or generated code it's best to update them in one commit and then make your changes in a separate commit. It just makes the review smaller (sometimes the code gen updates are very large!)

)
}

for i in 0 ..< 10 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid using direct indexing if possible; not all collections in Swift use integer indexing and those that do aren't required for the indexes to be monotonically increasing.

In this case use enumerated(), something like:

for (index, (descriptor, status)) in testServiceDescriptors.enumerated() {
  // ...
}

let statuses = try response.message.statuses
XCTAssertTrue(statuses.count == i + 1)

for j in 0 ... i {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid using direct indexing again, use:

for (descriptor, status) in testServiceDescriptors.prefix(index + 1) {
 // ...
}

testServiceDescriptors[j].1
)

XCTAssertEqual(receivedStatus!, expectedStatus)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general avoid the ! if possible, where it isn't possible add a brief comment saying why it's okay.

In this instance you can use let status = try XCTUnwrap(receivedStatus) to get the status or exit the test otherwise.

let receivedServerStatus = statuses[""]?.status
XCTAssertNotNil(receivedServerStatus)

XCTAssertEqual(receivedServerStatus!, .serving)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid the ! here

let receivedServerStatus = statuses[""]?.status
XCTAssertNotNil(receivedServerStatus)

XCTAssertEqual(receivedServerStatus!, .notServing)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid the ! here

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Jun 27, 2025
@glbrntt
Copy link
Collaborator

glbrntt commented Jun 27, 2025

The API breakage check failures are a false positive (the symbols were added at package level):

  💔 API breakage: func Grpc_Health_V1_Health.StreamingServiceProtocol.list(request:context:) has been added as a protocol requirement
  💔 API breakage: func Grpc_Health_V1_Health.ClientProtocol.list(request:serializer:deserializer:options:onResponse:) has been added as a protocol requirement

Comment on lines +66 to +67
// The server may respond with a RESOURCE_EXHAUSTED error if too many services
// exist.
Copy link
Contributor Author

@yigityazicilar yigityazicilar Jun 27, 2025

Choose a reason for hiding this comment

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

Also, I am not sure about this line in the proto file. Should I add a limit? In the proposal it was limited to 100.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, that's a good callout. Go uses the limit of 100, we should do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the limit should be good to merge

* Moved out the empty case to its own test
* Removed the usages of `!`
* Stopped using direct indexing
* Changed to the shorthand API
@yigityazicilar yigityazicilar requested a review from glbrntt June 27, 2025 15:08
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @yigityazicilar!

@glbrntt glbrntt merged commit e047830 into grpc:main Jun 27, 2025
25 of 26 checks passed
@yigityazicilar yigityazicilar deleted the gRFCA90 branch June 27, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants