-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Recent change to metadata broke backward compatibility #1178
Comments
This is intentional. Because we think that in most use cases:
There's no way to make It seems that you are trying to read the outgoing metadata on the client side, which falls into the use cases that will be broken by the change (sorry about the breakage). Please use More on that, |
Sounds good, thanks for clarifying. |
BTW, I read the original issue (#1148) and understand the problem, but the solution is somewhat annoying to use in other cases where a library function could be used to fill in the context of either a client or a server. Now the library functions have to either be duplicated or receive a flag indicating whether or not we're filling in incoming or outgoing metadata. |
Actually, the mechanism to send metadata is different between client and server. To send metadata on client side, users need to add the metadata to the context which will be used to make the RPC. To send metadata on server side, users need to call functions like Reading is also different... More details on this are available in this doc. So |
However, functions trying to read metadata from context will have the issue you mentioned. In this case, I think it's kind of reasonable to add a flag to indicate which metadata to read. Because a context may have both the incoming and outgoing metadata. The caller of this metadata-reading-function needs to specify which one to read somehow. |
I wonder if this metadata change in grpc-go would be backward compatible with grpc-java? |
Interoperability is not affected by this change. The metadata is sent and received on the wire the same way. This only changes the way the metadata is represented in contexts within Go binaries. |
Great. Thanks for clarifying. |
In commit 0c1d39d, @dfawley split out metadata into incoming and outgoing metadata. In doing so, the old APIs
NewContext
andFromContext
have been changed to wrap the new APIs, however nowNewContext
creates outgoing metadata andFromContext
looks for incoming metadata, which means thatFromContext(NewContext(ctx, md))
doesn't return the metadata anymore.I'm not sure whether this intentional or not, since it looks like the change was written to preserve backward compatibility, this may just be a bug due to a small oversight. Please advise on what the intent was here and whether this can be fixed.
The text was updated successfully, but these errors were encountered: