dotnet / dotnet/extensions

[API Proposal]: HttpKey usage

Open
#7,535 1 comment 0 reactions 0 assignees View on GitHub
api-suggestion area-resilience untriaged
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Background and motivation

Re: Microsoft.Extensions.Http.Resilience, Microsoft.Extensions.DependencyInjection

So `HttpKey` is currently not a public API member. When registering resilience handlers on an `IHttpClientBuilder` using the `AddResilienceHandler` extension, it creates an `HttpResiliencePipelineBuilder` by calling `AddHttpResiliencePipeline`.

AFAICT all documentation that deals with "advanced" scenarios, like executing a pipeline using `ExecuteAsync` with a given `ResilienceContext`, requires a `ResiliencePipelineProvider` or `ResiliencePipelineRegistry` with a key type of `string`. When using DI to request such a provider, it is not currently possible to reference a type of `ResiliencePipelineProvider` because `HttpKey` is an internal type.

### API Proposal

```csharp
internal readonly record struct HttpKey(string Name, string InstanceName)
```

should be

```csharp
public readonly record struct HttpKey(string Name, string InstanceName)
```

### API Usage

```csharp
ResiliencePipelineProvider theRegisteredProvider,
```

### Alternative Designs

Provide guidance on how to accomplish advanced scenarios when using `AddResilienceHandler`

### Risks

_No response_

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.