GRPC ——官网

Posted 晴天彩虹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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()));
...

以上是关于GRPC ——官网的主要内容,如果未能解决你的问题,请参考以下文章

gRPC golang开发简介

Vue3官网-高级指南(十七)响应式计算`computed`和侦听`watchEffect`(onTrackonTriggeronInvalidate副作用的刷新时机`watch` pre)(代码片段

gRPC试用

gRPC详解

grpc:使用 golang 开发 grpc 服务端和client

Rust与gRPC的那些事