grpc-go README

The project's README from github.com/grpc/grpc-go. As one markdown file: README.md.

gRPC-Go

GoDoc GoReportCard codecov

The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the Go gRPC docs, or jump directly into the quick start.

Prerequisites

Installation

Simply add the following import to your code, and then go [build|run|test] will automatically fetch the necessary dependencies:

import "google.golang.org/grpc"

Note: If you are trying to access grpc-go from China, see the FAQ below.

Learn more

FAQ

I/O Timeout Errors

The golang.org domain may be blocked from some countries. go get usually produces an error like the following when this happens:

$ go get -u google.golang.org/grpc
package google.golang.org/grpc: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

To build Go code, there are several options:

Compiling error, undefined: grpc.SupportPackageIsVersion

Please update to the latest version of gRPC-Go using go get google.golang.org/grpc.

How to turn on logging

The default logger is controlled by environment variables. Turn everything on like this:

$ export GRPC_GO_LOG_VERBOSITY_LEVEL=99
$ export GRPC_GO_LOG_SEVERITY_LEVEL=info

The RPC failed with error "code = Unavailable desc = transport is closing"

This error means the connection the RPC is using was closed, and there are many possible reasons, including:

  1. mis-configured transport credentials, connection failed on handshaking
  2. bytes disrupted, possibly by a proxy in between
  3. server shutdown
  4. Keepalive parameters caused connection shutdown, for example if you have configured your server to terminate connections regularly to trigger DNS lookups. If this is the case, you may want to increase your MaxConnectionAgeGrace, to allow longer RPC calls to finish.

It can be tricky to debug this because the error happens on the client side but the root cause of the connection being closed is on the server side. Turn on logging on both client and server, and see if there are any transport errors.

grpc-go (grpc/grpc-go)

Searching Database…

23.1K ·GitHub
这是什么?gRPC 的 Go 语言实现:一个高性能、开源的通用 RPC 框架,以移动端和 HTTP/2 为优先。你可以用它来在 Go 中构建 gRPC 客户端和服务器。
gRPC-Go 是我部署的服务,还是写代码时引用的库?是一个需要导入到你自己的 Go 程序中的库(README 称它为通用 RPC 框架)。客户端和服务器代码都用它来编写;没有可以独立运行的二进制程序或服务。
怎么把它加到项目里?在代码中添加 google.golang.org/grpc 导入,之后 go build、go run 和 go test 就会自动拉取所需的依赖。
我需要先装哪个版本的 Go?最新的两个 Go 大版本中的任意一个即可。
在连接方面有什么已知的坑吗?最经典的坑是 'code = Unavailable desc = transport is closing' 这个报错:RPC 所用的连接被关闭了 —— 常见原因包括传输凭据配置错误、代理干扰了字节流、服务器关闭,或 keepalive 参数设置不当。
有没有可以先看看的基准测试或示例代码?有 —— 这个仓库链接了性能基准测试,并自带示例,另外在 Go gRPC 官方文档里还有底层技术文档和快速上手指南。
这个项目成熟度怎么样?它从 2014 年 12 月开始开发,在 GitHub 上约有 23k 星标,其 CI 运行着 CodeQL、覆盖率、依赖检查和 govulncheck 工作流。
它只适合微服务吗?不是 —— README 称它为通用 RPC 框架;它的 GitHub 话题标签确实突出了 microservices、rpc 和 proto,但没有任何东西把它限制在这个用途上。
What are similar projects?grpc-java, grpc-rust, brpc, kratos, flatbuffers, chi, fiber, grpc-gateway
Creator
grpc
Size
45.5 MB
Stars
23.1K
Age
11y
Commits · 90 Days