Hello all,
I am currently doing some tests using the Callout-based Service Extensions with python sdk.
My current uses case:
This seems to work fine, however:
My question is: do you know if this is possible in this current implementation?
Thanks and best regards
Hello @laurodd,
I understand that you would like to know if there is a way to share the data between on_request and on_response using Callout-based Service Extensions with python sdk. Please correct me if I misunderstood.
Please be noted that it is possible to share data between the on_request and on_response phases by using Flask HTTP Middleware. The key to sharing data between on_request and on_response phases is to use a context object or a similar mechanism that is accessible throughout the lifecycle of the request which can be achieved by using Flask HTTP Middleware. This allows you to store data during the request handling phase and retrieve it during the response phase, facilitating the sharing of data between these phases.
For more information regarding this, please refer to :
I hope the above provided information is helpful.
Thanks & Regards,
Manish Bavireddy.
Hello @Manish_B Thanks a lot for your comment! 😀
I was wondering how I could run flask in this context? Can you help me on that?
I ask that because the doc is saying the following:
A load balancer communicates with a callout extension by using Envoy's ext proc gRPC API. This API lets the extension service respond to events in the lifecycle of an HTTP request by examining and modifying the headers or the body of the request.
So, following the example "Developing callouts" github page:
if __name__ == '__main__': CalloutServer().run()
So, I don't understand how we could actually use a WSGI(flask) inside the gRPC server and the callbacks.
If you could give more details about it, I would really appreciate it;
thanks and best regards
Hello @laurodd,
Thanks for your response.
Yes! your understanding is correct, Flask is an HTTP server, while gRPC is an RPC (Remote Procedure Call) framework that works over HTTP/2. They are fundamentally different in how they handle requests. However, you can integrate them to work together. Please refer to this blog for more information.
In addition to the information provided earlier, you could use metadata to share data between on_request and on_response phases using callout-based service extensions in a gRPC server. gRPC metadata is a key-value pair of data that is sent with initial or final gRPC requests or responses. It is used to provide additional information about the call, such as authentication credentials, tracing information, or custom headers.
For more information, please refer to :
I hope this is helpful!
Thanks & Regards,
Manish Bavireddy