• GRPC ——官网


    官网

    Guides

    Task-oriented walkthroughs of common use cases

    The documentation covers the following techniques:


    Authentication

    An overview of gRPC authentication, including built-in auth mechanisms, and how to plug in your own authentication systems.

    Benchmarking

    gRPC is designed to support high-performance open-source RPCs in many languages. This page describes performance benchmarking tools, scenarios considered by tests, and the testing infrastructure.

    Error handling

    How gRPC deals with errors, and gRPC error codes.

    Error status codes

    Errors are raised by gRPC under various circumstances, from network failures to unauthenticated connections, each of which is associated with a particular status code. The following error status codes are supported in all gRPC languages.

    General errors

    CaseStatus code
    Client application cancelled the request GRPC_STATUS_CANCELLED
    Deadline expired before server returned status GRPC_STATUS_DEADLINE_EXCEEDED
    Method not found on server GRPC_STATUS_UNIMPLEMENTED
    Server shutting down GRPC_STATUS_UNAVAILABLE
    Server threw an exception (or did something other than returning a status code to terminate the RPC) GRPC_STATUS_UNKNOWN

    Network failures

    CaseStatus code
    No data transmitted before deadline expires. Also applies to cases where some data is transmitted and no other failures are detected before the deadline expires GRPC_STATUS_DEADLINE_EXCEEDED
    Some data transmitted (for example, the request metadata has been written to the TCP connection) before the connection breaks GRPC_STATUS_UNAVAILABLE

    Protocol errors

    CaseStatus code
    Could not decompress but compression algorithm supported GRPC_STATUS_INTERNAL
    Compression mechanism used by client not supported by the server GRPC_STATUS_UNIMPLEMENTED
    Flow-control resource limits reached GRPC_STATUS_RESOURCE_EXHAUSTED
    Flow-control protocol violation GRPC_STATUS_INTERNAL
    Error parsing returned status GRPC_STATUS_UNKNOWN
    Unauthenticated: credentials failed to get metadata GRPC_STATUS_UNAUTHENTICATED
    Invalid host set in authority metadata GRPC_STATUS_UNAUTHENTICATED
    Error parsing response protocol buffer GRPC_STATUS_INTERNAL
    Error parsing request protocol buffer GRPC_STATUS_INTERNAL

    C#

    Base case - no encryption or authentication
    var channel = new Channel("localhost:50051", ChannelCredentials.Insecure);
    var client = new Greeter.GreeterClient(channel);
    ...
    
    With server authentication SSL/TLS
    var channelCredentials = new SslCredentials(File.ReadAllText("roots.pem"));  // Load a custom roots file.
    var channel = new Channel("myservice.example.com", channelCredentials);
    var client = new Greeter.GreeterClient(channel);
    
    Authenticate with Google
    using Grpc.Auth;  // from Grpc.Auth NuGet package
    ...
    // Loads Google Application Default Credentials with publicly trusted roots.
    var channelCredentials = await GoogleGrpcCredentials.GetApplicationDefaultAsync();
    
    var channel = new Channel("greeter.googleapis.com", channelCredentials);
    var client = new Greeter.GreeterClient(channel);
    ...
    
    Authenticate a single RPC call
    var channel = new Channel("greeter.googleapis.com", new SslCredentials());  // Use publicly trusted roots.
    var client = new Greeter.GreeterClient(channel);
    ...
    var googleCredential = await GoogleCredential.GetApplicationDefaultAsync();
    var result = client.SayHello(request, new CallOptions(credentials: googleCredential.ToCallCredentials()));
    ...
    
    
  • 相关阅读:
    动态网络社团检测学习笔记 --- 随机块模型小结之简介
    十五组第四次作业
    17现代软件工程十五组第二次作业
    17现代软件工程十五组第三次作业
    现代软件工程2017十五组成员介绍
    软件测试学习日志3 ————软件测试作业之控制流图
    软件测试学习日志———— round 2 Junit+intellj idea 安装及简单的测试使用
    软件测试学习日志————round 1 some questions of two small programs
    [关于printPrime是()方法的控制流图和点覆盖、边覆盖、主路径覆盖]
    【在myeclipse中使用Junit(4.12), Hamcrest(1.3) 和Eclemma】
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/14768486.html
Copyright © 2020-2023  润新知