You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As in the above code, 3 instances of the same webapi service are started. Before . The package for NET 9 P3, Microsoft.Extensions.ServiceDiscovery, can be used like this:
builder.Services.ConfigureHttpClientDefaults(static http =>
{
// Turn on service discovery by default
http.UseServiceDiscovery(RandomServiceEndPointSelectorProvider.Instance);
});
I wonder if there is a similar way to implement load balancing in Aspire
About Forward
In one project, there is a gateway and some microservices. In general, the gateway accesses the API of the access registry, and the service registry automatically creates the corresponding HttpClient instance through load balancing and other methods to forward the request to the corresponding microservice.
Such as:
app.MapGet("/CallGetApi",
async (IHttpClientFactory factory, ILogger<Program> logger) =>
{
var client = factory.CreateClient("shipping");
HealthCheckResult healthCheckResult;
do
{
var healthCheckService = new ShippingHealthCheck(factory);
healthCheckResult = await healthCheckService.CheckHealthAsync(new HealthCheckContext { });
if (healthCheckResult.Status != HealthStatus.Healthy)
{
logger.LogError("Shipping service is not healthy.");
client = factory.CreateClient("shipping");
}
}
while (healthCheckResult.Status != HealthStatus.Healthy);
var response = await client.GetStringAsync(
$"http://shippingForProcessString/ProcessString/SendToProcessNumber");
return $"Shipping ProcessString API returned: {response}";
});
I wonder if there is a similar operation in the AppHost project in Aspire?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
About LoadBalance
As in the above code, 3 instances of the same webapi service are started. Before . The package for NET 9 P3,
Microsoft.Extensions.ServiceDiscovery
, can be used like this:I wonder if there is a similar way to implement load balancing in Aspire
About Forward
In one project, there is a gateway and some microservices. In general, the gateway accesses the API of the access registry, and the service registry automatically creates the corresponding HttpClient instance through load balancing and other methods to forward the request to the corresponding microservice.
Such as:
I wonder if there is a similar operation in the AppHost project in Aspire?
Beta Was this translation helpful? Give feedback.
All reactions