dotnet / dotnet/yarp

How to handle routes with logic to different Clusters?

Open
#1,159 11 comments 0 reactions 0 assignees View on GitHub
samsp_list Type: Enhancement
Dominant language
C#
Stars
9.6k
Forks
933
Avg merge
12d 18h
Merged PRs (30d)
2

Description

What is the best way to conditionally choose a different Cluster to proxy request to?

For example, ideally I'd like to have an application with 2 Clusters (`foo` and `bar`) and a route with `"clusterId": "foo"` and I want to, depending on some logic applied to an incoming request, use cluster `bar`. Is this possible?

I'm currently using the [Direct Forwarding](https://microsoft.github.io/reverse-proxy/articles/direct-forwarding.html) but that means I lose out on load balancing to Clusters. I can apply any logic I need and change path/destination but without load balancing etc. Is it possible to get access to something that handles this, similar to how `IHttpForwarder` is used? With this method it looks like I'd need to send the request to another load-balancer for `bar` and let that do the load balancing.

I had a look at `ITransformFactory` but that looks like it is transforming requests/responses to/from a specified Cluster, rather than changing the target cluster.

Is this possible?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.