ServiceModel.Grpc.AspNetCore
1.11.0
dotnet add package ServiceModel.Grpc.AspNetCore --version 1.11.0
NuGet\Install-Package ServiceModel.Grpc.AspNetCore -Version 1.11.0
<PackageReference Include="ServiceModel.Grpc.AspNetCore" Version="1.11.0" />
paket add ServiceModel.Grpc.AspNetCore --version 1.11.0
#r "nuget: ServiceModel.Grpc.AspNetCore, 1.11.0"
// Install ServiceModel.Grpc.AspNetCore as a Cake Addin #addin nuget:?package=ServiceModel.Grpc.AspNetCore&version=1.11.0 // Install ServiceModel.Grpc.AspNetCore as a Cake Tool #tool nuget:?package=ServiceModel.Grpc.AspNetCore&version=1.11.0
ServiceModel.Grpc.AspNetCore
ServiceModel.Grpc
enables applications to communicate with gRPC services using a code-first approach (no .proto files), helps to get around limitations of gRPC protocol like "only reference types", "exact one input", "no nulls", "no value-types". Provides exception handling. Helps to migrate existing WCF solution to gRPC with minimum effort.
ServiceModel.Grpc.AspNetCore
is package with code-first extensions for Grpc.AspNetCore.Server.
Declare a service contract and implement service
A service contract is an interface decorated with the ServiceContract
attribute. Interface methods decorated with the OperationContract
attribute are treated as gRPC operations.
For example, following ICalculator
contract with unary Sum
operation and client streaming MultiplyBy
operation:
[ServiceContract]
public interface ICalculator
{
[OperationContract]
Task<long> Sum(long x, int y, int z, CancellationToken token = default);
[OperationContract]
ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token = default);
}
internal sealed class Calculator : ICalculator
{
public Task<long> Sum(long x, int y, int z, CancellationToken token) => x + y + z;
public ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token)
{
var multiplicationResult = DoMultiplication(values, multiplier, token);
return new ValueTask<(int, IAsyncEnumerable<int>)>((multiplier, multiplicationResult));
}
private static async IAsyncEnumerable<int> DoMultiplication(IAsyncEnumerable<int> values, int multiplier, [EnumeratorCancellation] CancellationToken token)
{
await foreach (var value in values.WithCancellation(token))
{
yield return value * multiplier;
}
}
}
Configure service
Enable ServiceModel.Grpc code-first and add service to the routing pipeline.
var builder = WebApplication.CreateBuilder();
// optional Grpc.AspNetCore.Server configuration
builder.Services.AddGrpc(options =>
{
// ...
});
// enable ServiceModel.Grpc code-first
builder.Services.AddServiceModelGrpc(options =>
{
options.DefaultMarshallerFactory = ...
options.DefaultErrorHandlerFactory = ...
options.Filters = ...
});
var app = builder.Build();
// bind the service
app.MapGrpcService<Calculator>();
app.Run();
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net6.0
- Grpc.AspNetCore.Server (>= 2.67.0)
- ServiceModel.Grpc (>= 1.11.0)
-
net8.0
- Grpc.AspNetCore.Server (>= 2.67.0)
- ServiceModel.Grpc (>= 1.11.0)
-
net9.0
- Grpc.AspNetCore.Server (>= 2.67.0)
- ServiceModel.Grpc (>= 1.11.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on ServiceModel.Grpc.AspNetCore:
Package | Downloads |
---|---|
ServiceModel.Grpc.AspNetCore.Swashbuckle
Library that enables applications to communicate with gRPC services using code-first approach, helps to get around some limitations of gRPC protocol. Provides exception handling. Helps to migrate existing WCF solution to gRPC with minimum effort. |
|
ServiceModel.Grpc.AspNetCore.NSwag
Library that enables applications to communicate with gRPC services using code-first approach, helps to get around some limitations of gRPC protocol. Provides exception handling. Helps to migrate existing WCF solution to gRPC with minimum effort. |
|
MF40.Silo
Orleans Silo |
|
CleanTemplate.Grpc
A Clean Architecture Base Template comprising all Baseic and Abstract and Contract types for Grpc Communication. |
|
AbrPlus.Integration.OpenERP.Hosting
Copyright © AbrPlus 2024 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.11.0 | 27 | 11/23/2024 |
1.10.1 | 2,287 | 10/19/2024 |
1.9.1 | 1,194 | 9/29/2024 |
1.9.0 | 4,777 | 7/21/2024 |
1.8.3 | 7,861 | 5/18/2024 |
1.8.2 | 4,292 | 3/2/2024 |
1.8.1 | 2,502 | 2/13/2024 |
1.8.0 | 6,796 | 1/7/2024 |
1.7.0 | 567 | 12/24/2023 |
1.6.1 | 8,190 | 11/25/2023 |
1.6.0 | 15,038 | 9/9/2023 |
1.5.2 | 7,817 | 6/25/2023 |
1.5.1 | 7,582 | 5/1/2023 |
1.5.0 | 4,974 | 3/7/2023 |
1.4.13 | 13,619 | 12/19/2022 |
1.4.12 | 1,514 | 11/19/2022 |
1.4.11 | 1,308 | 10/23/2022 |
1.4.10 | 2,561 | 8/14/2022 |
1.4.9 | 1,275 | 7/23/2022 |
1.4.8 | 11,042 | 5/29/2022 |
1.4.7 | 928 | 5/21/2022 |
1.4.6 | 2,185 | 4/3/2022 |
1.4.5 | 987 | 3/26/2022 |
1.4.4 | 29,991 | 3/12/2022 |
1.4.3 | 1,153 | 2/5/2022 |
1.4.2 | 1,265 | 1/22/2022 |
1.4.1 | 612 | 1/8/2022 |
1.4.0 | 2,724 | 11/26/2021 |
1.3.2 | 608 | 11/5/2021 |
1.3.1 | 2,846 | 10/10/2021 |
1.3.0 | 797 | 7/31/2021 |
1.2.1 | 767 | 6/12/2021 |
1.2.0 | 387 | 6/6/2021 |
1.1.9 | 385 | 5/8/2021 |
1.1.8 | 523 | 3/28/2021 |
1.1.7 | 471 | 1/3/2021 |
1.1.6 | 449 | 12/13/2020 |
1.1.5 | 403 | 11/21/2020 |
1.1.4 | 473 | 10/11/2020 |
1.1.3 | 594 | 9/13/2020 |
1.1.2 | 421 | 8/26/2020 |
1.1.1 | 462 | 6/21/2020 |
1.1.0 | 504 | 5/10/2020 |
1.0.1 | 468 | 5/1/2020 |
1.0.0 | 636 | 4/23/2020 |
1.0.0-pre2 | 351 | 4/18/2020 |
1.0.0-pre1 | 366 | 4/16/2020 |