cockroach: Index | Files

package grpcutil

import ""


Package Files

grpc_util.go log.go


var ErrCannotReuseClientConn = errors.New("cannot reuse client connection")

ErrCannotReuseClientConn is returned when a failed connection is being reused. We require that new connections be created with pkg/rpc.GRPCDial instead.

func ConnectionReady Uses

func ConnectionReady(conn *grpc.ClientConn) error

ConnectionReady returns nil if the given connection is ready to send a request, or an error (which will pass RequestDidNotStart) if not.

This is a workaround for the fact that gRPC 1.7 fails to distinguish between ambiguous and unambiguous errors.

This is designed for use with connections prepared by pkg/rpc.Connection.Connect (which performs an initial heartbeat and thereby ensures that we will never see a connection in the first-time Connecting state).

func IsClosedConnection Uses

func IsClosedConnection(err error) bool

IsClosedConnection returns true if err's Cause is an error produced by gRPC on closed connections.

func IsContextCanceled Uses

func IsContextCanceled(err error) bool

IsContextCanceled returns true if err's Cause is an error produced by gRPC on context cancellation.

func IsLocalRequestContext Uses

func IsLocalRequestContext(ctx context.Context) bool

IsLocalRequestContext returns true if this context is marked for local (in-process) use.

func IsTimeout Uses

func IsTimeout(err error) bool

IsTimeout returns true if err's Cause is a gRPC timeout, or the request was canceled by a context timeout.

func NewLocalRequestContext Uses

func NewLocalRequestContext(ctx context.Context) context.Context

NewLocalRequestContext returns a Context that can be used for local (in-process) requests.

func RequestDidNotStart Uses

func RequestDidNotStart(err error) bool

RequestDidNotStart returns true if the given error from gRPC means that the request definitely could not have started on the remote server.

This method currently depends on implementation details, matching on the text of an error message that is known to only be used in this case in the version of gRPC that we use today. We will need to watch for changes here in future versions of gRPC. TODO(bdarnell): Replace this with a cleaner mechanism when/if is resolved.

func SetSeverity Uses

func SetSeverity(s log.Severity)

SetSeverity sets the severity level below which GRPC log messages are suppressed.

Must be called before GRPC is used.

Package grpcutil imports 17 packages (graph) and is imported by 201 packages. Updated 2020-08-09. Refresh now. Tools for package owners.