Propagating gRPC context in Python

1.3k views Asked by At

There are two python gRPC services A and B.
Service A needs to call a rpc on service B in order to send a response to the client.
Service A also has an interceptor that adds information to gRPC contexts it uses.

Question:
How can I pass the gRPC context to service B so I can access those information on gRPC contexts in service B?

1

There are 1 answers

0
Borna Arzi On

Since you are changing the python object itself, it is not currently possible to pass it in the gRPC call. although you can do this manually by setting your metadata using send_initial_metadata method of your context and writing a new interceptor in service B to parse this information stored in invocation_metadata and setting it in the context of your second service.