Grpc.Net.ClientFactory 2.66.0
Grpc.Net.ClientFactory
gRPC integration with HttpClientFactory
offers a centralized way to create gRPC clients. It can be used as an alternative to configuring stand-alone gRPC client instances.
The factory offers the following benefits:
- Provides a central location for configuring logical gRPC client instances
- Manages the lifetime of the underlying
HttpClientMessageHandler
- Automatic propagation of deadline and cancellation in an ASP.NET Core gRPC service
Register gRPC clients
To register a gRPC client, the generic AddGrpcClient
extension method can be used within Startup.ConfigureServices
, specifying the gRPC typed client class and service address:
services.AddGrpcClient<Greeter.GreeterClient>(o =>
{
o.Address = new Uri("https://localhost:5001");
});
The gRPC client type is registered as transient with dependency injection (DI). The client can now be injected and consumed directly in types created by DI. ASP.NET Core MVC controllers, SignalR hubs and gRPC services are places where gRPC clients can automatically be injected:
public class AggregatorService : Aggregator.AggregatorBase
{
private readonly Greeter.GreeterClient _client;
public AggregatorService(Greeter.GreeterClient client)
{
_client = client;
}
public override async Task SayHellos(HelloRequest request,
IServerStreamWriter<HelloReply> responseStream, ServerCallContext context)
{
// Forward the call on to the greeter service
using (var call = _client.SayHellos(request))
{
await foreach (var response in call.ResponseStream.ReadAllAsync())
{
await responseStream.WriteAsync(response);
}
}
}
}
Links
No packages depend on Grpc.Net.ClientFactory.
.NET 6.0
- Grpc.Net.Client (>= 2.66.0)
- Microsoft.Extensions.Http (>= 6.0.0)
.NET Standard 2.1
- Microsoft.Extensions.Http (>= 6.0.0)
- Grpc.Net.Client (>= 2.66.0)
.NET Standard 2.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Grpc.Net.Client (>= 2.66.0)
.NET 8.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Grpc.Net.Client (>= 2.66.0)
.NET 7.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Grpc.Net.Client (>= 2.66.0)
Version | Downloads | Last updated |
---|---|---|
2.67.0 | 0 | 21.11.2024 |
2.67.0-pre1 | 0 | 22.10.2024 |
2.66.0 | 1 | 10.12.2024 |
2.66.0-pre1 | 0 | 06.09.2024 |
2.65.0 | 0 | 27.07.2024 |
2.65.0-pre1 | 0 | 20.07.2024 |
2.64.0 | 0 | 19.07.2024 |
2.64.0-pre1 | 0 | 15.07.2024 |
2.63.0 | 0 | 24.05.2024 |
2.63.0-pre1 | 0 | 08.05.2024 |
2.62.0 | 0 | 29.03.2024 |
2.62.0-pre1 | 0 | 08.03.2024 |
2.61.0 | 0 | 22.02.2024 |
2.61.0-pre1 | 0 | 08.02.2024 |
2.60.0 | 0 | 03.01.2024 |
2.60.0-pre1 | 0 | 14.12.2023 |
2.59.0 | 0 | 08.11.2023 |
2.59.0-pre1 | 0 | 27.10.2023 |
2.58.0 | 0 | 19.10.2023 |
2.58.0-pre1 | 0 | 09.10.2023 |
2.57.0 | 0 | 06.09.2023 |
2.57.0-pre1 | 0 | 31.08.2023 |
2.56.0 | 0 | 25.08.2023 |
2.56.0-pre2 | 0 | 16.08.2023 |
2.56.0-pre1 | 0 | 03.08.2023 |
2.55.0 | 0 | 04.07.2023 |
2.55.0-pre1 | 0 | 23.06.2023 |
2.54.0 | 0 | 15.06.2023 |
2.54.0-pre1 | 0 | 25.05.2023 |
2.53.0 | 0 | 05.05.2023 |
2.53.0-pre1 | 0 | 12.04.2023 |
2.52.0 | 0 | 15.03.2023 |
2.52.0-pre1 | 0 | 03.03.2023 |
2.51.0 | 0 | 02.01.2023 |
2.51.0-pre1 | 0 | 07.12.2022 |
2.50.0 | 0 | 17.11.2022 |
2.50.0-pre1 | 0 | 03.11.2022 |
2.49.0 | 0 | 26.09.2022 |
2.49.0-pre1 | 0 | 01.09.2022 |
2.48.0 | 0 | 24.08.2022 |
2.48.0-pre1 | 0 | 17.08.2022 |
2.47.0 | 0 | 03.07.2022 |
2.47.0-pre1 | 0 | 23.06.2022 |
2.46.0 | 0 | 13.05.2022 |
2.46.0-pre1 | 0 | 28.04.2022 |
2.45.0 | 0 | 19.04.2022 |
2.45.0-pre1 | 0 | 07.04.2022 |
2.44.0 | 0 | 17.03.2022 |
2.44.0-pre1 | 0 | 09.03.2022 |
2.43.0 | 0 | 25.02.2022 |
2.43.0-pre1 | 0 | 28.01.2022 |
2.42.0 | 0 | 19.01.2022 |
2.42.0-pre1 | 0 | 30.12.2021 |
2.41.0 | 0 | 07.12.2021 |
2.41.0-pre1 | 0 | 12.11.2021 |
2.40.0 | 0 | 05.10.2021 |
2.40.0-pre1 | 0 | 09.09.2021 |
2.39.0 | 0 | 18.08.2021 |
2.39.0-pre1 | 0 | 06.08.2021 |
2.38.0 | 0 | 11.06.2021 |
2.38.0-pre1 | 0 | 04.06.2021 |
2.37.0 | 0 | 20.04.2021 |
2.37.0-pre1 | 0 | 14.04.2021 |
2.36.0 | 0 | 17.03.2021 |
2.36.0-pre1 | 0 | 09.03.2021 |
2.35.0 | 0 | 04.02.2021 |
2.35.0-pre1 | 0 | 26.01.2021 |
2.34.0 | 0 | 11.12.2020 |
2.34.0-pre1 | 0 | 01.12.2020 |
2.33.1 | 0 | 28.10.2020 |
2.33.1-pre1 | 0 | 22.10.2020 |
2.32.0 | 0 | 05.10.2020 |
2.32.0-pre1 | 0 | 08.09.2020 |
2.31.0 | 0 | 14.08.2020 |
2.31.0-pre2 | 0 | 03.08.2020 |
2.30.0 | 0 | 16.07.2020 |
2.30.0-pre1 | 0 | 17.06.2020 |
2.29.0 | 0 | 27.05.2020 |
2.29.0-pre1 | 0 | 15.05.2020 |
2.28.0 | 0 | 09.04.2020 |
2.28.0-pre2 | 0 | 11.03.2020 |
2.28.0-pre1 | 0 | 03.03.2020 |
2.27.0 | 0 | 07.02.2020 |
2.27.0-pre1 | 0 | 24.01.2020 |
2.26.0 | 0 | 19.12.2019 |
2.26.0-pre1 | 0 | 10.12.2019 |
2.25.0 | 0 | 07.11.2019 |
2.25.0-pre1 | 0 | 01.11.2019 |
2.24.0 | 0 | 21.10.2019 |
2.24.0-pre1 | 0 | 09.10.2019 |
2.23.2 | 0 | 20.09.2019 |
0.2.23-pre2 | 0 | 06.09.2019 |
0.2.23-pre1 | 0 | 21.08.2019 |
0.1.22-pre3 | 0 | 30.07.2019 |
0.1.22-pre2 | 0 | 02.07.2019 |
0.1.22-pre1 | 0 | 17.06.2019 |
0.1.21-pre1 | 0 | 04.06.2019 |