ServiceModel.Grpc
1.11.0
dotnet add package ServiceModel.Grpc --version 1.11.0
NuGet\Install-Package ServiceModel.Grpc -Version 1.11.0
<PackageReference Include="ServiceModel.Grpc" Version="1.11.0" />
paket add ServiceModel.Grpc --version 1.11.0
#r "nuget: ServiceModel.Grpc, 1.11.0"
// Install ServiceModel.Grpc as a Cake Addin #addin nuget:?package=ServiceModel.Grpc&version=1.11.0 // Install ServiceModel.Grpc as a Cake Tool #tool nuget:?package=ServiceModel.Grpc&version=1.11.0
ServiceModel.Grpc
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
is package with main functionality, basic Grpc.Core.Api extensions and ClientFactory.
Declare a service contract
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);
}
Configure ClientFactory
ClientFactory
serves to configure and create instances of gRPC service clients.
IClientFactory defaultClientFactory
= new ClientFactory(new ServiceModelGrpcClientOptions
{
MarshallerFactory = ...
DefaultCallOptionsFactory = () => ...
ErrorHandler = ...
Logger = ...
ServiceProvider = ...
Filters = ...
});
Configure a gRPC channel
A channel represents a long-lived connection to a gRPC service.
Grpc.Net.Client.GrpcChannel
from Grpc.Net.Client NuGet package.
ChannelBase channel = GrpcChannel.ForAddress("http://localhost:5000");
Grpc.Core.Channel
from Grpc.Core NuGet package.
ChannelBase channel = new Channel("localhost", 5000, ChannelCredentials.Insecure);
Make gRPC calls
A gRPC call is initiated by calling a method on the client. The gRPC client will handle message serialization and addressing the gRPC call to the correct service.
ICalculator calculator = clientFactory.CreateClient<ICalculator>(channel);
// call Sum: sum == 6
var sum = await calculator.Sum(1, 2, 3);
// call MultiplyBy: multiplier == 2, values == [] {2, 4, 6}
var (multiplier, values) = await calculator.MultiplyBy(new[] {1, 2, 3}, 2);
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- ServiceModel.Grpc.Core (>= 1.11.0)
- ServiceModel.Grpc.Emit (>= 1.11.0)
-
.NETStandard 2.0
- ServiceModel.Grpc.Core (>= 1.11.0)
- ServiceModel.Grpc.Emit (>= 1.11.0)
-
.NETStandard 2.1
- ServiceModel.Grpc.Core (>= 1.11.0)
- ServiceModel.Grpc.Emit (>= 1.11.0)
-
net8.0
- ServiceModel.Grpc.Core (>= 1.11.0)
- ServiceModel.Grpc.Emit (>= 1.11.0)
-
net9.0
- ServiceModel.Grpc.Core (>= 1.11.0)
- ServiceModel.Grpc.Emit (>= 1.11.0)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on ServiceModel.Grpc:
Package | Downloads |
---|---|
ServiceModel.Grpc.AspNetCore
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.ProtoBufMarshaller
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.DesignTime
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.SelfHost
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.MessagePackMarshaller
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. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on ServiceModel.Grpc:
Repository | Stars |
---|---|
6bee/Remote.Linq
Simply LINQ your remote resources...
|
Version | Downloads | Last updated |
---|---|---|
1.11.0 | 956 | 11/23/2024 |
1.10.1 | 5,625 | 10/19/2024 |
1.9.1 | 2,454 | 9/29/2024 |
1.9.0 | 9,344 | 7/21/2024 |
1.8.3 | 12,447 | 5/18/2024 |
1.8.2 | 6,008 | 3/2/2024 |
1.8.1 | 5,176 | 2/13/2024 |
1.8.0 | 8,282 | 1/7/2024 |
1.7.0 | 912 | 12/24/2023 |
1.6.1 | 10,345 | 11/25/2023 |
1.6.0 | 19,173 | 9/9/2023 |
1.5.2 | 12,775 | 6/25/2023 |
1.5.1 | 19,204 | 5/1/2023 |
1.5.0 | 8,185 | 3/7/2023 |
1.4.13 | 15,447 | 12/19/2022 |
1.4.12 | 2,814 | 11/19/2022 |
1.4.11 | 2,810 | 10/23/2022 |
1.4.10 | 6,083 | 8/14/2022 |
1.4.9 | 2,741 | 7/23/2022 |
1.4.8 | 12,824 | 5/29/2022 |
1.4.7 | 2,228 | 5/21/2022 |
1.4.6 | 4,083 | 4/3/2022 |
1.4.5 | 2,190 | 3/26/2022 |
1.4.4 | 31,165 | 3/12/2022 |
1.4.3 | 2,362 | 2/5/2022 |
1.4.2 | 21,441 | 1/22/2022 |
1.4.1 | 1,170 | 1/8/2022 |
1.4.0 | 3,678 | 11/26/2021 |
1.3.2 | 1,250 | 11/5/2021 |
1.3.1 | 3,485 | 10/10/2021 |
1.3.0 | 1,874 | 7/31/2021 |
1.2.1 | 1,452 | 6/12/2021 |
1.2.0 | 1,101 | 6/6/2021 |
1.1.9 | 1,999 | 5/8/2021 |
1.1.8 | 1,221 | 3/28/2021 |
1.1.7 | 965 | 1/3/2021 |
1.1.6 | 941 | 12/13/2020 |
1.1.5 | 966 | 11/21/2020 |
1.1.4 | 1,035 | 10/11/2020 |
1.1.3 | 1,204 | 9/13/2020 |
1.1.2 | 953 | 8/26/2020 |
1.1.1 | 934 | 6/21/2020 |
1.1.0 | 965 | 5/10/2020 |
1.0.1 | 1,007 | 5/1/2020 |
1.0.0 | 1,248 | 4/23/2020 |
1.0.0-pre2 | 594 | 4/18/2020 |
1.0.0-pre1 | 468 | 4/16/2020 |