MCPcopy
hub / github.com/grpc/grpc-go

github.com/grpc/grpc-go @v1.82.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.82.0 ↗
13,286 symbols 74,713 edges 1,033 files 5,744 documented · 43%
README

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:

  • Set up a VPN and access google.golang.org through that.

  • With Go module support: it is possible to use the replace feature of go mod to create aliases for golang.org packages. In your project's directory:

sh go mod edit -replace=google.golang.org/grpc=github.com/grpc/grpc-go@latest go mod tidy go mod vendor go build -mod=vendor

Again, this will need to be done for all transitive dependencies hosted on golang.org as well. For details, refer to golang/go issue #28652.

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 1. bytes disrupted, possibly by a proxy in between 1. server shutdown 1. 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.

Extension points exported contracts — how you extend this code

ServerOption (Interface)
A ServerOption sets options such as credentials, codec and keepalive parameters, etc. [9 implementers]
server.go
DialOption (Interface)
DialOption configures how we set up the connection. [9 implementers]
dialoptions.go
Decompressor (Interface)
Decompressor defines the interface gRPC uses to decompress a message. Deprecated: use package encoding. [6 implementers]
rpc_util.go
ServerStreamingClient (Interface)
ServerStreamingClient represents the client side of a server-streaming (one request, many responses) RPC. It is generic [12 …
stream_interfaces.go
PerRPCCredentials (Interface)
PerRPCCredentials defines the common interface for the credentials which need to attach security information to every RP [13 …
credentials/credentials.go
Provider (Interface)
Provider makes it possible to keep channel credential implementations up to date with secrets that they rely on to secur [7 …
credentials/tls/certprovider/provider.go
Sink (Interface)
Sink represents the destination for the binary log entries. [10 implementers]
binarylog/sink.go
ConfigParser (Interface)
ConfigParser parses load balancer configs. [30 implementers]
balancer/balancer.go

Core symbols most depended-on inside this repo

Fatalf
called by 5741
grpclog/internal/logger.go
Fatal
called by 1775
grpclog/internal/logger.go
Errorf
called by 1397
trace.go
Errorf
called by 1299
internal/testutils/resolver.go
Close
called by 669
balancer/balancer.go
String
called by 577
codec.go
WithTransportCredentials
called by 511
dialoptions.go
NewClient
called by 479
clientconn.go

Shape

Method 7,705
Function 3,139
Struct 1,998
Interface 274
TypeAlias 127
FuncType 43

Languages

Go100%

Modules by API surface

channelz/grpc_channelz_v1/channelz.pb.go419 symbols
test/end2end_test.go292 symbols
interop/grpc_testing/messages.pb.go288 symbols
interop/grpc_testing/control.pb.go255 symbols
interop/grpc_testing/test_grpc.pb.go177 symbols
credentials/alts/internal/proto/grpc_gcp/handshaker.pb.go143 symbols
rpc_util.go126 symbols
server.go117 symbols
binarylog/grpc_binarylog_v1/binarylog.pb.go112 symbols
internal/transport/transport_test.go109 symbols
reflection/grpc_reflection_v1alpha/reflection.pb.go97 symbols
reflection/grpc_reflection_v1/reflection.pb.go97 symbols

Dependencies from manifests, versioned

cel.dev/exprv0.25.1 · 1×
cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/authv0.20.0 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
cloud.google.com/go/loggingv1.16.0 · 1×
cloud.google.com/go/longrunningv0.11.0 · 1×
cloud.google.com/go/monitoringv1.27.0 · 1×
cloud.google.com/go/tracev1.14.0 · 1×
codeberg.org/chavacava/garifv0.2.1 · 1×
contrib.go.opencensus.io/exporter/stackdriverv0.13.15-0.202307021 · 1×
github.com/BurntSushi/tomlv1.6.0 · 1×

For agents

$ claude mcp add grpc-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact