SyZero.DynamicGrpc
1.1.6-dev.1
This is a prerelease version of SyZero.DynamicGrpc.
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 SyZero.DynamicGrpc --version 1.1.6-dev.1
NuGet\Install-Package SyZero.DynamicGrpc -Version 1.1.6-dev.1
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="SyZero.DynamicGrpc" Version="1.1.6-dev.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyZero.DynamicGrpc" Version="1.1.6-dev.1" />
<PackageReference Include="SyZero.DynamicGrpc" />
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 SyZero.DynamicGrpc --version 1.1.6-dev.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SyZero.DynamicGrpc, 1.1.6-dev.1"
#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 SyZero.DynamicGrpc@1.1.6-dev.1
#: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=SyZero.DynamicGrpc&version=1.1.6-dev.1&prerelease
#tool nuget:?package=SyZero.DynamicGrpc&version=1.1.6-dev.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SyZero.DynamicGrpc
SyZero 的动态 gRPC 模块,基于 protobuf-net.Grpc.AspNetCore 自动注册 Code-First gRPC 服务。
安装
dotnet add package SyZero.DynamicGrpc
使用
1. 定义应用服务
using SyZero.Application.Attributes;
using SyZero.Application.Service;
[DynamicApi]
public interface IUserAppService : IDynamicApi
{
Task<UserDto> GetUserAsync(long id);
}
public class UserAppService : IUserAppService
{
public Task<UserDto> GetUserAsync(long id)
{
return Task.FromResult(new UserDto { Id = id });
}
}
2. 注册服务
var builder = WebApplication.CreateBuilder(args);
builder.AddSyZero();
// 方式 1:扫描当前已加载的业务程序集
builder.Services.AddDynamicGrpc();
// 方式 2:只扫描指定程序集
builder.Services.AddDynamicGrpc(typeof(UserAppService).Assembly);
// 方式 3:结合配置进一步覆盖选项
builder.Services.AddDynamicGrpc(options =>
{
options.EnableDetailedErrors = true;
options.MaxReceiveMessageSize = 8 * 1024 * 1024;
});
3. 映射端点
var app = builder.Build();
app.MapDynamicGrpcServices();
app.Run();
配置
{
"DynamicGrpc": {
"MaxReceiveMessageSize": 4194304,
"MaxSendMessageSize": 4194304,
"EnableDetailedErrors": false
}
}
可用配置项:
| 属性 | 类型 | 说明 |
|---|---|---|
MaxReceiveMessageSize |
int? |
最大接收消息大小,单位字节 |
MaxSendMessageSize |
int? |
最大发送消息大小,单位字节 |
EnableDetailedErrors |
bool |
是否输出详细错误信息 |
约束
- 服务实现类型必须是
public、非抽象、非泛型类。 - 服务必须实现
IDynamicApi,并通过[DynamicApi]启用。 - 标注
[NonDynamicApi]或[NonGrpcService]的服务不会注册为 gRPC 服务。 - 标记为
IFallback的类型不会被注册。
许可证
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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.
-
net9.0
- Grpc.AspNetCore (>= 2.76.0)
- protobuf-net.Grpc.AspNetCore (>= 1.2.2)
- SyZero (>= 1.1.6-dev.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.9 | 95 | 4/19/2026 |
| 1.1.9-dev.2 | 45 | 4/19/2026 |
| 1.1.9-dev.1 | 58 | 4/17/2026 |
| 1.1.8 | 87 | 4/17/2026 |
| 1.1.6 | 91 | 4/17/2026 |
| 1.1.6-dev.1 | 46 | 4/17/2026 |
| 1.1.5 | 97 | 4/13/2026 |
| 1.1.5-dev.3 | 56 | 4/13/2026 |
| 1.1.5-dev.2 | 66 | 2/11/2026 |
| 1.1.5-dev.1 | 63 | 1/29/2026 |
| 1.1.4 | 108 | 1/2/2026 |
| 1.1.4-dev.2 | 66 | 1/2/2026 |
| 1.1.4-dev.1 | 64 | 12/30/2025 |
| 1.1.3 | 104 | 12/30/2025 |
| 1.1.3-dev.6 | 66 | 12/30/2025 |
| 1.0.0 | 92 | 4/17/2026 |