Skip to content

Conversation

@sauravzg
Copy link
Collaborator

Introduces the foundational Status and ServerStatus types for gRPC status handling.

  • Status: Represents a standard gRPC status with a code and message.
  • ServerStatus: A wrapper around Status designed to prevent accidental leakage of sensitive server errors to the client. This type distinction ensures that handlers must explicitly convert to Status, encouraging a conscious decision about what information is exposed.
  • StatusCode: Enum representing standard gRPC status codes.

This implementation provides the necessary types to unblock server-side API development without relying on a heavy tonic::Status. This is not meant to be an intermediate or final Status implementation but serves as a way to implement functional requirements while we design the final Status.

Introduces the foundational `Status` and `ServerStatus` types for gRPC status handling.

* `Status`: Represents a standard gRPC status with a code and message.
* `ServerStatus`: A wrapper around `Status` designed to prevent accidental leakage of sensitive server errors to the client. This type distinction ensures that handlers must explicitly convert to `Status`, encouraging a conscious decision about what information is exposed.
* `StatusCode`: Enum representing standard gRPC status codes.

This implementation provides the necessary types to unblock server-side API development. This is not meant to be an intermediate or final Status implementation but serves as a way to implement functional requirements while we design the final `Status`.
Copy link

@darth-raijin darth-raijin left a comment

Choose a reason for hiding this comment

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

I left one suggestion on the tests about avoiding duplication of the "ok" message by assigning it to a variable and reusing it in the assertions. It should make the test a bit less brittle if the message ever changes.


#[test]
fn test_status_new() {
let status = Status::new(StatusCode::Ok, "ok");

Choose a reason for hiding this comment

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

Right now the "ok" message is duplicated in both the constructor call and the assertion.

To make the test less brittle, I’d suggest assigning the message to a variable and reusing it, e.g.:

let message = "ok";
let status = Status::new(StatusCode::Ok, message);

assert_eq!(status.code(), StatusCode::Ok);
assert_eq!(status.message(), message);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants