rpc

package
v0.0.0-...-81f3bb6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientKeepalive = keepalive.ClientParameters{

	Time: helper.NetworkTimeout,

	Timeout: helper.NetworkTimeout,

	PermitWithoutStream: true,
}

To prevent unidirectional network partitions from keeping an unhealthy connection alive, we use both client-side and server-side keepalive pings.

View Source
var ClientTestingKeepalive = keepalive.ClientParameters{
	Time:                200 * time.Millisecond,
	Timeout:             300 * time.Millisecond,
	PermitWithoutStream: true,
}

These aggressively low keepalive timeouts ensure that tests which use them don't take too long.

View Source
var ServerEnforcement = keepalive.EnforcementPolicy{
	MinTime:             time.Nanosecond,
	PermitWithoutStream: true,
}

By default, gRPC disconnects clients that send "too many" pings, but we don't really care about that, so configure the server to be as permissive as possible.

View Source
var ServerTestingKeepalive = keepalive.ServerParameters{
	Time:    200 * time.Millisecond,
	Timeout: 300 * time.Millisecond,
}
View Source
var SourceAddr = func() net.Addr {
	const envKey = "NENTROPY_SOURCE_IP_ADDRESS"
	if sourceAddr, ok := envutil.EnvString(envKey, 0); ok {
		sourceIP := net.ParseIP(sourceAddr)
		if sourceIP == nil {
			panic(fmt.Sprintf("unable to parse %s '%s' as IP address", envKey, sourceAddr))
		}
		return &net.TCPAddr{
			IP: sourceIP,
		}
	}
	return nil
}()

SourceAddr provides a way to specify a source/local address for outgoing connections. It should only ever be set by testing code, and is not thread safe (so it must be initialized before the server starts).

Functions

func NewServer

func NewServer() *grpc.Server

NewServer is a thin wrapper around grpc.NewServer that registers a heartbeat service.

Types

type Context

type Context struct {
	*helper.Config

	AmbientCtx log.AmbientContext
	Stopper    *stop.Stopper
	// contains filtered or unexported fields
}

Context contains the fields required by the rpc framework.

func NewContext

func NewContext(
	ambient log.AmbientContext,
	baseCtx *helper.Config, stopper *stop.Stopper) *Context

NewContext creates an rpc Context with the supplied values.

func (*Context) GRPCDial

func (ctx *Context) GRPCDial(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

GRPCDial calls grpc.Dial with the options appropriate for the context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL