envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.75k stars 4.75k forks source link

Support outbound call within Envoy's cluster from Golang filter #35206

Open ardikabs opened 2 months ago

ardikabs commented 2 months ago

Title: Support outbound call within Envoy's cluster from Golang filter

Description: Currently, when there is a need to make outbound calls within Golang filter, the filter will handle by itself which is unfortunate that the current implementation cannot utilize Envoy's full capabilities, such as circuit-breaking, retry mechanisms, locality-aware routing, and other advanced features.

In comparison to the Lua filter, which has been supported through httpcall.

[optional Relevant Links:]

Any extra documentation required to understand the issue.

KBaichoo commented 2 months ago

cc @doujiang24

doujiang24 commented 2 months ago

Thanks, the API does make sense. But not a high priority for me now, patches/volunteers are welcome~

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

doujiang24 commented 1 month ago

@wbpcode please add no-stale, thanks

chenwan0036 commented 4 weeks ago

Hi @doujiang24,

I’m curious about what it would take to implement this. Which Envoy API call needs to be wrapped? Is there a similar example we could reference? Thanks.

doujiang24 commented 3 weeks ago

Hi @chenwan0036

There isn't a simple Envoy API to be wrapped, here are the key points:

  1. we have to implement Envoy C++ API, similar to Lua: https://github.com/envoyproxy/envoy/blob/main/source/extensions/filters/http/lua/lua_filter.cc#L156-L187
  2. after Golang invoke the Envoy C++ API, Golang should yield and wait Envoy call Golang to resume, i.e. https://github.com/envoyproxy/envoy/blob/main/contrib/golang/filters/http/source/golang_filter.cc#L1037
chenwan0036 commented 3 weeks ago

@doujiang24, thank you for your response. I’ve realized it’s more complex than I initially thought. I tried implementing an HTTP call (key point 1), but it was tougher than I expected, and I didn’t make much progress. This experience gave me a new appreciation for filter development and your work—it's truly impressive.