-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fix issue: grpc-previous-rpc-attempts not added to initial response metadata #9686
Conversation
|
You will have to sign the CLA before we can consider this PR |
@sanjaypujare I have signed the CLA. |
How does it fix #9641 ? That issue talks about adding |
I misunderstood the author's intention. I tried to fix it again. |
I have sought clarification in #9641 (comment) . I think @ejona86 was suggesting adding |
@@ -38,6 +38,9 @@ public final class ServerCalls { | |||
@VisibleForTesting | |||
static final String MISSING_REQUEST = "Half-closed without a request"; | |||
|
|||
static final Metadata.Key<String> GRPC_PREVIOUS_RPC_ATTEMPTS = |
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.
It will be nice to have a single definition shared with RetriableStream
. The current one RetriableStream.GRPC_PREVIOUS_RPC_ATTEMPTS
can be moved up to the common base class Stream
then we can eliminate this?
@@ -126,8 +129,12 @@ public ServerCall.Listener<ReqT> startCall(ServerCall<ReqT, RespT> call, Metadat | |||
Preconditions.checkArgument( | |||
call.getMethodDescriptor().getType().clientSendsOneMessage(), | |||
"asyncUnaryRequestCall is only for clientSendsOneMessage methods"); | |||
String preRpcAttempts = null; | |||
if (headers.containsKey(GRPC_PREVIOUS_RPC_ATTEMPTS)) { |
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 need this check? get
returns null if not present, so why can't we do :
String preRpcAttempts = headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS);
Same for line 241 (StreamingServerCallHandler.startCall
)
@@ -126,8 +129,12 @@ public ServerCall.Listener<ReqT> startCall(ServerCall<ReqT, RespT> call, Metadat | |||
Preconditions.checkArgument( | |||
call.getMethodDescriptor().getType().clientSendsOneMessage(), | |||
"asyncUnaryRequestCall is only for clientSendsOneMessage methods"); | |||
String preRpcAttempts = null; |
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.
previousRpcAttempts
(or at least prevRpcAttempts
) as a name is much better than preRpcAttempts
since pre as a short form of previous is not common
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.
There is not test case to test the added functionality. That will need to be there. Also added a few comments.
The intent was client-only, where the client library injects the value for the client application to see. Yes, it is strange. But that's what it is, since there are few ways for the library to communicate with the application. |
In that case @pandaapo you will have to change this PR to add the trailer in |
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.
Suggested changes in main code and test code. After that will approve
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
@ejona86 do you need to approve as well? |
@ejona86 you also need to approve it before we merge it? |
Thank you! |
Fixes #9641
Add
grpc-previous-rpc-attempts
to headers when response metadata is initialized.