pool

package
v1.6.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MPL-2.0 Imports: 12 Imported by: 59

Documentation

Index

Constants

View Source
const (
	// keep numbers unique.
	RPCConsul      RPCType = 0
	RPCRaft                = 1
	RPCMultiplex           = 2 // Old Muxado byte, no longer supported.
	RPCTLS                 = 3
	RPCMultiplexV2         = 4
	RPCSnapshot            = 5
	RPCGossip              = 6
	// RPCTLSInsecure is used to flag RPC calls that require verify
	// incoming to be disabled, even when it is turned on in the
	// configuration. At the time of writing there is only AutoEncryt.Sign
	// that is supported and it might be the only one there
	// ever is.
	RPCTLSInsecure = 7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is a pooled connection to a Consul server

func (*Conn) Close

func (c *Conn) Close() error

type ConnPool

type ConnPool struct {
	// SrcAddr is the source address for outgoing connections.
	SrcAddr *net.TCPAddr

	// LogOutput is used to control logging
	LogOutput io.Writer

	// The maximum time to keep a connection open
	MaxTime time.Duration

	// The maximum number of open streams to keep
	MaxStreams int

	// TLSConfigurator
	TLSConfigurator *tlsutil.Configurator

	// ForceTLS is used to enforce outgoing TLS verification
	ForceTLS bool

	sync.Mutex
	// contains filtered or unexported fields
}

ConnPool is used to maintain a connection pool to other Consul servers. This is used to reduce the latency of RPC requests between servers. It is only used to pool connections in the rpcConsul mode. Raft connections are pooled separately. Maintain at most one connection per host, for up to MaxTime. When MaxTime connection reaping is disabled. MaxStreams is used to control the number of idle streams allowed. If TLS settings are provided outgoing connections use TLS.

func (*ConnPool) DialTimeout

func (p *ConnPool) DialTimeout(dc string, addr net.Addr, timeout time.Duration, useTLS bool) (net.Conn, HalfCloser, error)

DialTimeout is used to establish a raw connection to the given server, with given connection timeout. It also writes RPCTLS as the first byte.

func (*ConnPool) DialTimeoutInsecure added in v1.5.2

func (p *ConnPool) DialTimeoutInsecure(dc string, addr net.Addr, timeout time.Duration, wrapper tlsutil.DCWrapper) (net.Conn, HalfCloser, error)

DialTimeoutInsecure is used to establish a raw connection to the given server, with given connection timeout. It also writes RPCTLSInsecure as the first byte to indicate that the client cannot provide a certificate. This is so far only used for AutoEncrypt.Sign.

func (*ConnPool) Ping

func (p *ConnPool) Ping(dc string, addr net.Addr, version int, useTLS bool) (bool, error)

Ping sends a Status.Ping message to the specified server and returns true if healthy, false if an error occurred

func (*ConnPool) RPC

func (p *ConnPool) RPC(dc string, addr net.Addr, version int, method string, useTLS bool, args interface{}, reply interface{}) error

RPC is used to make an RPC call to a remote host

func (*ConnPool) Shutdown

func (p *ConnPool) Shutdown() error

Shutdown is used to close the connection pool

type HalfCloser

type HalfCloser interface {
	CloseWrite() error
}

HalfCloser is an interface that exposes a TCP half-close. We need this because we want to expose the raw TCP connection underlying a TLS one in a way that's hard to screw up and use for anything else. There's a change brewing that will allow us to use the TLS connection for this instead - https://go-review.googlesource.com/#/c/25159/.

func DialTimeoutWithRPCType added in v1.5.2

func DialTimeoutWithRPCType(dc string, addr net.Addr, src *net.TCPAddr, timeout time.Duration, useTLS bool, wrapper tlsutil.DCWrapper, rpcType RPCType) (net.Conn, HalfCloser, error)

type RPCType

type RPCType byte

type StreamClient

type StreamClient struct {
	// contains filtered or unexported fields
}

streamClient is used to wrap a stream with an RPC client

func (*StreamClient) Close

func (sc *StreamClient) Close()

Jump to

Keyboard shortcuts

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