-
Notifications
You must be signed in to change notification settings - Fork 3.9k
How can I share some value without sharing Context.Key object instance? #7024
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
Comments
You're correct that multiple
You need to use the same |
Thank you for your answer. I was missing the doc of Context.key API.
public static <T> Key<T> key() {
return new Key<>(DEFAULT_KEY_NAME);
} |
Since the question here is resolved, I'm going to mark this issue as closed (discussion on the updates can continue on the PR). Thanks! |
Summary
How can I store and get a value from Context without sharing Context.Key instance?
Detail
I want to share some value with grpc Context. but I can't get the stored value with Context.Key instance
I tried this snippet
The result was
But I expected
It means if I want to get value from a Context, I should use same Context.Key instance.
It is strange. Because, I'm trying to share some values with Context and when I get the stored value I should use same Context.Key.
To share some value, should share the key object instance. (not the key value)
For example (with kotlin)
If I can share
myKey
object instance, I don't need Context to share value.What about multi-threaded case? It is more difficult to share the Context.Key object instance.
I can't understand use of Context and Context.key to share value.
In short, My question is.
How can I store and get a value from Context without sharing Context.Key instance?
The text was updated successfully, but these errors were encountered: