I did the threadlocal version. I added an Atmonic...
# grpc
t
I did the threadlocal version. I added an AtmonicReference<String> as a threadLocal/contextElement. In the stubb, I get the Threadlocal and set the value. In the interceptor, I get the threadLocal then get the value and set it. But.. That's a lot of pain, and I'm not even sure the "post interceptor" is even running on the same thread after the "stub service method" runs.
m
So you're trying to get the client-sent metadata from within the server-side gRPC stub correct? I've seen many examples that use io.grpc.Context to store the metadata which uses the methods you listed ( ThreadLocal or CoroutineContext ) to transfer the context according to which stub you use (coroutine or not) If you use this, you won't have to implement the ThreadLocal approach yourself. There are also other options like using a framework that does the same thing to provide Request Context (like armeria) but I think io.grpc.Context + Interceptors is what you were looking for examples: https://www.tabnine.com/code/java/classes/io.grpc.Contexts
** I'm not 100% sure about the internals though since I didn't go through it myself 😅
t
Late response. What I wanted to do is in server code, send trailers.
🥲 1