How to intercept the headers from in call to one service and insert it to another request in gRPC-java?

后端 未结 1 995
不思量自难忘°
不思量自难忘° 2020-12-20 07:05

I have two servers - HelloServer and WorldServer.

Both implement the same proto file:

// The greeting service         


        
1条回答
  •  醉梦人生
    2020-12-20 07:57

    The expected approach is to use a ClientInterceptor and ServerInterceptor. The client interceptor would copy from Context into Metadata. The server interceptor would copy from Metadata to Context. Use Contexts.interceptCall in the server interceptor to apply the Context all callbacks.

    Metadata is for wire-level propagation. Context is for in-process propagation. Generally the application should not need to interact directly with Metadata (in Java).

    0 讨论(0)
提交回复
热议问题