Skip to content

Add gRPC status codes #137

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 6 commits into from
Dec 9, 2024
Merged

Add gRPC status codes #137

merged 6 commits into from
Dec 9, 2024

Conversation

moleike
Copy link
Contributor

@moleike moleike commented Oct 16, 2024

An attempt at solving #135.

Copy link
Contributor

@hamnis hamnis left a comment

Choose a reason for hiding this comment

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

Looks good to me, leaving for @danicheg to merge.

Copy link
Member

@danicheg danicheg left a comment

Choose a reason for hiding this comment

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

Thanks for adding this! I mainly agree with the approach, a few (minor) questions/suggestions from me:

Comment on lines +8 to +9
def asStatusRuntimeException(message: Option[String] = None): StatusRuntimeException =
StatusRuntimeException(this, message)
Copy link
Member

Choose a reason for hiding this comment

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

Is it legit for the Ok status to be considered as StatusRuntimeException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it feels weird. We could further divide codes into success and errors.

Copy link
Contributor

@i10416 i10416 Nov 1, 2024

Choose a reason for hiding this comment

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

Just passing by, but I think we should take gRPC richer error model into consideration for error handling design because there are more and more gRPC implementations that can send extra error details in trailers header(e.g. golang, Java or Rust implementation).

See

for more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danicheg How about making the status Ok package private, since user code should never need it anyways?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we have to drop it from the codeValues list which is kind of weird.
Do we really need to care if users want to shoot themselves in the foot?

Copy link
Contributor Author

@moleike moleike Dec 9, 2024

Choose a reason for hiding this comment

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

@hamnis good point. If we need to be cautious, I would include an assertion in asStatusRuntimeException to prevent Ok from being treated as an exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to do that go ahead.

@hamnis hamnis merged commit fc8e3b2 into http4s:main Dec 9, 2024
11 checks passed
@moleike moleike deleted the add-status-codes branch December 10, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants