dotnet / dotnet/yarp

How to expose cluster address resolution for backend-to-backend calls?

Open
#3,004 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
9.6k
Forks
933
Avg merge
12d 18h
Merged PRs (30d)
2

Description

YARP is designed around the reverse proxy pipeline, but I have a use case where I need to call downstream services directly from the backend.

Im working in a microservice orchestrator (BFF-style) architecture, where the backend aggregates JSON data (e.g., config, menus) from multiple services.

Ideally, Id like to reuse YARP’s cluster configuration and load balancing logic to resolve a destination and call it via `HttpClient`, something like:

```csharp
var url = await yarpResolver.GetDestinationAsync(clusterId);
var result = await httpClient.GetAsync(url);
```

### Question

Is there a way to resolve a cluster destination (including load balancing/health checks) outside the proxy pipeline?

If not, would it make sense to expose something like:

```csharp
public interface IClusterAddressResolver
{
ValueTask GetDestinationAsync(string clusterId, CancellationToken cancellationToken = default);
}
```

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.