pool

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MPL-2.0 Imports: 15 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

func PeekFirstByte added in v1.7.3

func PeekFirstByte(conn net.Conn) (net.Conn, byte, error)

PeekFirstByte will read the first byte on the conn.

This function does not close the conn on an error.

The returned conn has the initial read buffered internally for the purposes of not consuming the first byte. After that buffer is drained the conn is a pass through to the original conn.

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) (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, 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 without exposing the underlying TLS or raw TCP connection.

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