microsoft / microsoft/aspire

Add extension methods to make adding HTTP & gRPC service references + optionally health checks easier

Open
#898 1 comment 0 reactions 0 assignees View on GitHub
area-service-discovery
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

The [eShopLite sample](https://github.com/dotnet/aspire-samples/tree/main/samples/eShopLite) includes a [set of extension methods](https://github.com/dotnet/aspire-samples/blob/main/samples/eShopLite/eShopLite.ServiceDefaults/ServiceReferenceExtensions.cs) intended to make it easier to add HTTP and gRPC service references to service projects and optionally adding health checks for those services too.

Here's how they look in the WebFrontend's *Program.cs* file where the clients are being configured in the app's DI:

```csharp
builder.Services.AddHttpServiceReference("http://catalogservice", healthRelativePath: "readiness");

builder.Services.AddSingleton()
.AddGrpcServiceReference("http://basketservice", failureStatus: HealthStatus.Degraded);
```

These methods currently:
- Accept the URL directly as a `string` parameter, so that a client-accepting callback does not need to be passed just to set the base URL
- Optionally accept parameters related to configuring a URI health check for the service, so that the app's health is tied to the service's availability

We could also consider having these methods automate the selection of an appropriate scheme to use for the service, but that might very likely be better handled by a [feature in Service Discovery](https://github.com/dotnet/aspire/issues/381).

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.