-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Change status package to deal with concrete types instead of interfaces #1171
Conversation
status/status.go
Outdated
if s.Code() == codes.OK { | ||
return nil | ||
} | ||
return (*statusError)(proto.Clone(s.s).(*spb.Status)) |
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.
Why do we still make a clone here?
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.
To make it impossible to mutate the statusError and change the Code into OK.
Without this, but the rest of the code as-is, one could do:
status := status.New(codes.Internal, "blah")
p := status.Proto()
err := status.Err()
p.Code = int32(codes.OK)
Maybe status.Proto() and FromProto() should do the clone instead, making Status immutable, which is how I had it initially.
transport/transport.go
Outdated
@@ -335,7 +335,7 @@ func (s *Stream) Read(p []byte) (n int, err error) { | |||
|
|||
// finish sets the stream's state and status, and closes the done channel. | |||
// s.mu must be held by the caller. | |||
func (s *Stream) finish(st status.Status) { | |||
func (s *Stream) finish(st *status.Status) { |
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.
Comment this should never be called with nil?
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.
Done
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.
LGTM
No description provided.