zoukankan      html  css  js  c++  java
  • .net core 原生支持grpc

    This is a guest post by Sourabh Shirhatti, a Program Manger on the .NET team at Microsoft.

    The .NET team at Microsoft has been working in close collaboration with the gRPC team since November 2018 on a new fully managed implementation of gRPC for .NET Core.

    We’re pleased to announce that grpc-dotnet is now available with .NET Core 3.0 today!

    How to get it?

    grpc-dotnet packages have just been released to NuGet.org and are already available for use in your projects. These packages also require the latest .NET Core 3.0 shared framework. You can download the .NET Core 3.0 SDK for your dev machine and build servers from the .NET Core 3.0 download page to acquire the shared framework.

    Getting Started

    As gRPC is now a first-class citizen in .NET ecosystem, gRPC templates are included as part of the .NET SDK. To get started, navigate to a console window after installing the SDK and run the following commands.

    dotnet new grpc -o GrpcGreeter
    cd GrpcGreeter
    dotnet run

    To create a gRPC client and test with the newly created gRPC Greeter service, you can follow the rest of this tutorial here.

    Doesn’t gRPC already work with .NET Core?

    There are currently two official implementations of gRPC for .NET:

    • Grpc.Core: The original gRPC C# implementation based on the native gRPC Core library.
    • grpc-dotnet: The new implementation written entirely in C# with no native dependencies and based on the newly released .NET Core 3.0.

    The implementations coexist side-by-side and each has its own advantages in terms of available features, integrations, supported platforms, maturity level and performance. Both implementations share the same API for invoking and handling RPCs, thus limiting the lock-in and enabling users to choose the implementation that satisfies their needs the best.

    What’s new?

    Unlike the existing C-Core based implementation (Grpc.Core), the new libraries (grpc-dotnet) make use of the existing networking primitives in the .NET Core Base Class Libraries (BCL). The diagram below highlights the difference between the existing Grpc.Core library and the new grpc-dotnet libraries.

    On the server side, the Grpc.AspNetCore.Server package integrates into ASP.NET Core, allowing developers to benefit from ecosystem of common cross-cutting concerns of logging, configuration, dependency injection, authentication, authorization etc. which have already been solved by ASP.NET Core. Popular libraries in the ASP.NET ecosystem such as Entity Framework Core (ORM)Serilog (Logging library), and Identity Server among others now work seamlessly with gRPC.

    On the client side, the Grpc.Net.Client package builds upon the familiar HttpClient API that ships as part of .NET Core. As with the server, gRPC clients greatly benefit from the ecosystem of packages that build upon HttpClient. It is now possible to use existing packages such as Polly(Resilience and fault-handling library) and HttpClientFactory(manage HTTPClient lifetimes) with gRPC clients.

    The diagram below captures the exhaustive list of all new .NET packages for gRPC and their relationship with the existing packages.

    In addition to the newly published packages that ship as part of grpc-dotnet, we’ve also made improvements that benefit both stacks. Visual Studio 2019 ships with language grammar support for protobuf files and automatic generation of gRPC server/client code upon saving a protobuf file without requiring full project rebuilds due to design-time builds.

     

  • 相关阅读:
    go语言第一问:在其他地方执行编译go语言程序,结果会在哪个地方产生?
    ip地址获取无效,自己修改ip地址
    linux和windows双向互通的压缩包格式zip
    在notepad++中tab和空格的区别
    Django ----- app 和 ORM的操作和介绍
    Mysql --- 索引
    Mysql --创建用户和授权,备份
    Mysql --数据的增删改
    Mysql -- 外键的变种 三种关系
    Mysql -- 完整性约束
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/11581469.html
Copyright © 2011-2022 走看看