• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..24-Mar-2022-

attributes/H24-Mar-2022-10049

backoff/H24-Mar-2022-5314

balancer/H24-Mar-2022-1,484708

binarylog/grpc_binarylog_v1/H24-Mar-2022-1,188918

codes/H24-Mar-2022-308107

connectivity/H24-Mar-2022-9549

credentials/H24-Mar-2022-5,8273,771

encoding/H24-Mar-2022-324150

grpclog/H24-Mar-2022-599336

health/H24-Mar-2022-822555

internal/H24-Mar-2022-14,4779,407

keepalive/H24-Mar-2022-8620

metadata/H24-Mar-2022-248129

peer/H24-Mar-2022-5218

reflection/grpc_reflection_v1alpha/H24-Mar-2022-1,233954

resolver/H24-Mar-2022-494198

serviceconfig/H24-Mar-2022-4511

stats/H24-Mar-2022-384150

status/H24-Mar-2022-13666

tap/H24-Mar-2022-578

xds/H24-Mar-2022-16,67510,086

AUTHORSH A D24-Mar-202212 21

CODE-OF-CONDUCT.mdH A D24-Mar-2022138 42

CONTRIBUTING.mdH A D24-Mar-20223 KiB6246

GOVERNANCE.mdH A D24-Mar-2022141 21

LICENSEH A D24-Mar-202211.1 KiB203169

MAINTAINERS.mdH A D24-Mar-20221.3 KiB2924

MakefileH A D24-Mar-2022900 4735

README.mdH A D24-Mar-20224.7 KiB142101

SECURITY.mdH A D24-Mar-2022202 42

backoff.goH A D24-Mar-20221.9 KiB6215

balancer_conn_wrappers.goH A D24-Mar-20228.1 KiB293213

call.goH A D24-Mar-20222.4 KiB7536

clientconn.goH A D24-Mar-202255.2 KiB1,7321,224

codec.goH A D24-Mar-20221.6 KiB5116

codegen.shH A D24-Mar-2022635 182

dialoptions.goH A D24-Mar-202221.3 KiB618297

doc.goH A D24-Mar-2022786 271

interceptor.goH A D24-Mar-20225.2 KiB10220

picker_wrapper.goH A D24-Mar-20224.7 KiB178122

pickfirst.goH A D24-Mar-20224.4 KiB156114

preloader.goH A D24-Mar-20221.9 KiB6834

regenerate.shH A D24-Mar-20224.6 KiB12070

resolver_conn_wrapper.goH A D24-Mar-20225.9 KiB188143

rpc_util.goH A D24-Mar-202227.8 KiB915520

server.goH A D24-Mar-202256.6 KiB1,8681,335

service_config.goH A D24-Mar-202211.8 KiB405283

stream.goH A D24-Mar-202248.1 KiB1,6191,162

trace.goH A D24-Mar-20222.9 KiB12478

version.goH A D24-Mar-2022683 232

vet.shH A D24-Mar-20226.4 KiB212156

README.md

1# gRPC-Go
2
3[![Build Status](https://travis-ci.org/grpc/grpc-go.svg)](https://travis-ci.org/grpc/grpc-go)
4[![GoDoc](https://pkg.go.dev/badge/google.golang.org/grpc)][API]
5[![GoReportCard](https://goreportcard.com/badge/grpc/grpc-go)](https://goreportcard.com/report/github.com/grpc/grpc-go)
6
7The [Go][] implementation of [gRPC][]: A high performance, open source, general
8RPC framework that puts mobile and HTTP/2 first. For more information see the
9[Go gRPC docs][], or jump directly into the [quick start][].
10
11## Prerequisites
12
13- **[Go][]**: any one of the **three latest major** [releases][go-releases].
14
15## Installation
16
17With [Go module][] support (Go 1.11+), simply add the following import
18
19```go
20import "google.golang.org/grpc"
21```
22
23to your code, and then `go [build|run|test]` will automatically fetch the
24necessary dependencies.
25
26Otherwise, to install the `grpc-go` package, run the following command:
27
28```console
29$ go get -u google.golang.org/grpc
30```
31
32> **Note:** If you are trying to access `grpc-go` from **China**, see the
33> [FAQ](#FAQ) below.
34
35## Learn more
36
37- [Go gRPC docs][], which include a [quick start][] and [API
38  reference][API] among other resources
39- [Low-level technical docs](Documentation) from this repository
40- [Performance benchmark][]
41- [Examples](examples)
42
43## FAQ
44
45### I/O Timeout Errors
46
47The `golang.org` domain may be blocked from some countries. `go get` usually
48produces an error like the following when this happens:
49
50```console
51$ go get -u google.golang.org/grpc
52package 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)
53```
54
55To build Go code, there are several options:
56
57- Set up a VPN and access google.golang.org through that.
58
59- Without Go module support: `git clone` the repo manually:
60
61  ```sh
62  git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
63  ```
64
65  You will need to do the same for all of grpc's dependencies in `golang.org`,
66  e.g. `golang.org/x/net`.
67
68- With Go module support: it is possible to use the `replace` feature of `go
69  mod` to create aliases for golang.org packages.  In your project's directory:
70
71  ```sh
72  go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest
73  go mod tidy
74  go mod vendor
75  go build -mod=vendor
76  ```
77
78  Again, this will need to be done for all transitive dependencies hosted on
79  golang.org as well. For details, refer to [golang/go issue #28652](https://github.com/golang/go/issues/28652).
80
81### Compiling error, undefined: grpc.SupportPackageIsVersion
82
83#### If you are using Go modules:
84
85Ensure your gRPC-Go version is `require`d at the appropriate version in
86the same module containing the generated `.pb.go` files.  For example,
87`SupportPackageIsVersion6` needs `v1.27.0`, so in your `go.mod` file:
88
89```go
90module <your module name>
91
92require (
93    google.golang.org/grpc v1.27.0
94)
95```
96
97#### If you are *not* using Go modules:
98
99Update the `proto` package, gRPC package, and rebuild the `.proto` files:
100
101```sh
102go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
103go get -u google.golang.org/grpc
104protoc --go_out=plugins=grpc:. *.proto
105```
106
107### How to turn on logging
108
109The default logger is controlled by environment variables. Turn everything on
110like this:
111
112```console
113$ export GRPC_GO_LOG_VERBOSITY_LEVEL=99
114$ export GRPC_GO_LOG_SEVERITY_LEVEL=info
115```
116
117### The RPC failed with error `"code = Unavailable desc = transport is closing"`
118
119This error means the connection the RPC is using was closed, and there are many
120possible reasons, including:
121 1. mis-configured transport credentials, connection failed on handshaking
122 1. bytes disrupted, possibly by a proxy in between
123 1. server shutdown
124 1. Keepalive parameters caused connection shutdown, for example if you have configured
125    your server to terminate connections regularly to [trigger DNS lookups](https://github.com/grpc/grpc-go/issues/3170#issuecomment-552517779).
126    If this is the case, you may want to increase your [MaxConnectionAgeGrace](https://pkg.go.dev/google.golang.org/grpc/keepalive?tab=doc#ServerParameters),
127    to allow longer RPC calls to finish.
128
129It can be tricky to debug this because the error happens on the client side but
130the root cause of the connection being closed is on the server side. Turn on
131logging on __both client and server__, and see if there are any transport
132errors.
133
134[API]: https://pkg.go.dev/google.golang.org/grpc
135[Go]: https://golang.org
136[Go module]: https://github.com/golang/go/wiki/Modules
137[gRPC]: https://grpc.io
138[Go gRPC docs]: https://grpc.io/docs/languages/go
139[Performance benchmark]: https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5180705743044608
140[quick start]: https://grpc.io/docs/languages/go/quickstart
141[go-releases]: https://golang.org/doc/devel/release.html
142