gpt4 book ai didi

asp.net-core - Grpc.Net 与 Grpc.Core : What are the server side differences?

转载 作者:行者123 更新时间:2023-12-05 03:44:53 25 4
gpt4 key购买 nike

似乎 Grpc.Net 需要 ASP.NET Core 才能托管服务,而 Grpc.Core 不需要?有什么区别?首选哪一个?

Grpc.Net

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app.UseEndpoints(endpoints =>
{
// Communication with gRPC endpoints must be made through a gRPC client.
// To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909
endpoints.MapGrpcService<GreeterService>();
});
}

Grpc.Core

Server server = new Server
{
Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();

最佳答案

Grpc.Core是一个基于 gRPC 原生实现的库。它基本上是对 native 库的绑定(bind),可以直接将“原始”gRPC 用于客户端和服务器目的。

Grpc.AspNetCore是 gRPC 的托管重新实现,它构建在 Kestrel 服务器堆栈之上。与 native 实现相比,这使得 Grpc.AspNetCore 通常更加高效。它是为 ASP.NET Core 本身构建的,它还可以更好地集成到 ASP.NET Core 应用程序中,这还允许您与其他 ASP.NET Core 端点并排托管 gRPC 服务。相比之下,它可能不支持所有 gRPC 功能,并且也仅限于服务器端方面。

关于asp.net-core - Grpc.Net 与 Grpc.Core : What are the server side differences?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66190612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com