LinKit.Grpc
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package LinKit.Grpc --version 1.0.0
NuGet\Install-Package LinKit.Grpc -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LinKit.Grpc" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinKit.Grpc" Version="1.0.0" />
<PackageReference Include="LinKit.Grpc" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LinKit.Grpc --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LinKit.Grpc, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LinKit.Grpc@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LinKit.Grpc&version=1.0.0
#tool nuget:?package=LinKit.Grpc&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LinKit.Grpc
LinKit.Grpc extends LinKit.Core to provide automatic gRPC server and client code generation based on your CQRS requests and handlers.
Features
- gRPC Server:
- Generate gRPC service implementations from CQRS requests marked with
[GrpcEndpoint]
. - No manual mapping or boilerplate needed.
- Generate gRPC service implementations from CQRS requests marked with
- gRPC Client:
- Generate mediator-based gRPC clients for remote CQRS requests.
- Seamless integration with LinKit mediator pattern.
- Automatic Mapping:
- Properties are mapped by name or via
[JsonPropertyName]
/mapping configuration.
- Properties are mapped by name or via
- AOT & Trimming Ready:
- Fully compatible with NativeAOT and trimming.
Installation
dotnet add package LinKit.Grpc
Quick Start
1. gRPC Server
Mark your CQRS request:
[GrpcEndpoint(typeof(MyServiceBase), "GetUser")]
public class GetUserQuery : IQuery<UserDto>
{
public int Id { get; set; }
}
Implement handler:
[CqrsHandler]
public class GetUserHandler : IQueryHandler<GetUserQuery, UserDto> { ... }
Register gRPC server:
builder.Services.AddLinKitGrpcServer();
app.MapGrpcService<LinKitMyService>();
2. gRPC Client
Mark your CQRS request:
[GrpcClient(typeof(MyServiceClient), "GetUserAsync")]
public class GetUserQuery : IQuery<UserDto>
{
public int Id { get; set; }
}
Register gRPC client:
builder.Services.AddLinKitGrpcClient();
builder.Services.AddSingleton<IGrpcChannelProvider, MyChannelProvider>();
Send request via mediator:
var result = await mediator.QueryAsync(new GetUserQuery { Id = 1 });
3. Channel Provider Example
public class MyChannelProvider : IGrpcChannelProvider
{
public GrpcChannel GetChannel(Type serviceClientType)
=> GrpcChannel.ForAddress("https://localhost:5001");
}
Configuration
- Use
[GrpcEndpoint]
on CQRS requests to expose them as gRPC server methods. - Use
[GrpcClient]
to generate gRPC client calls for remote services. - All mapping between CQRS requests/responses and gRPC messages is automatic.
- For custom mapping, use the Mapping Kit from LinKit.Core.
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Grpc.AspNetCore (>= 2.71.0)
- Grpc.Core (>= 2.46.6)
- LinKit.Core (>= 1.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.