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 |
| @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.
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?
| 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.
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)
| Preconditions.checkArgument( | ||
| call.getMethodDescriptor().getType().clientSendsOneMessage(), | ||
| "asyncUnaryRequestCall is only for clientSendsOneMessage methods"); | ||
| String preRpcAttempts = null; |
There was a problem hiding this comment.
previousRpcAttempts (or at least prevRpcAttempts) as a name is much better than preRpcAttempts since pre as a short form of previous is not common
sanjaypujare
left a comment
There was a problem hiding this comment.
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 |
sanjaypujare
left a comment
There was a problem hiding this comment.
Suggested changes in main code and test code. After that will approve
|
@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-attemptsto headers when response metadata is initialized.