Skip to content

Commit 3f9ce92

Browse files
committed
add SetUpstreamOverrideHost
Signed-off-by: doujiang24 <doujiang24@gmail.com>
1 parent a3aecf7 commit 3f9ce92

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

api/pkg/filtermanager/api/api.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,30 @@ type FilterProcessCallbacks interface {
264264

265265
type DecoderFilterCallbacks interface {
266266
FilterProcessCallbacks
267+
// Sets an upstream address override for the request. When the overridden host exists in the host list of the routed cluster
268+
// and can be selected directly, the load balancer bypasses its algorithm and routes traffic directly to the specified host.
269+
//
270+
// Here are some cases:
271+
// 1. Set a valid host(no matter in or not in the cluster), will route to the specified host directly and return 200.
272+
// 2. Set a non-IP host, C++ side will return error and not route to cluster.
273+
// 3. Set a unavaiable host, and the host is not in the cluster, will req the valid host in the cluster and rerurn 200.
274+
// 4. Set a unavaiable host, and the host is in the cluster, but not available(can not connect to the host), will req the unavaiable hoat and rerurn 503.
275+
// 5. Set a unavaiable host, and the host is in the cluster, but not available(can not connect to the host), and with retry. when first request with unavaiable host failed 503, the second request will retry with the valid host, then the second request will succeed and finally return 200.
276+
// 6. Set a unavaiable host with strict mode, and the host is in the cluster, will req the unavaiable host and rerurn 503.
277+
// 7. Set a unavaiable host with strict mode, and the host is not in the cluster, will req the unavaiable host and rerurn 503.
278+
// 8. Set a unavaiable host with strict mode and retry. when first request with unavaiable host failed 503, the second request will retry with the valid host, then the second request will succeed and finally return 200.
279+
// 9. Set a unavaiable host with strict mode and retry, and the host is not in the cluster, will req the unavaiable host and rerurn 503.
280+
//
281+
// The function takes two arguments:
282+
//
283+
// host (string): The upstream host address to use for the request. This must be a valid IP address(with port); otherwise, the
284+
// C++ side will throw an error.
285+
//
286+
// strict (boolean): Determines whether the HTTP request must be strictly routed to the requested
287+
// host. When set to ``true``, if the requested host is invalid, Envoy will return a 503 status code.
288+
// The default value is ``false``, which allows Envoy to fall back to its load balancing mechanism. In this case, if the
289+
// requested host is invalid, the request will be routed according to the load balancing algorithm and choose other hosts.
290+
SetUpstreamOverrideHost(host string, strict bool) error
267291
}
268292

269293
type EncoderFilterCallbacks interface {

api/plugins/tests/pkg/envoy/capi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ func (i *filterCallbackHandler) AddData([]byte, bool) {
572572
func (i *filterCallbackHandler) InjectData([]byte) {
573573
}
574574

575+
func (i *filterCallbackHandler) SetUpstreamOverrideHost(host string, strict bool) error {
576+
return nil
577+
}
578+
575579
func (i *filterCallbackHandler) LookupConsumer(_, _ string) (api.Consumer, bool) {
576580
return nil, false
577581
}

0 commit comments

Comments
 (0)