pgwire

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrSSLRequired is returned when a client attempts to connect to a
	// secure server in cleartext.
	ErrSSLRequired = "node is running secure mode, SSL connection required"

	// ErrDraining is returned when a client attempts to connect to a server
	// which is not accepting client connections.
	ErrDraining = "server is not accepting clients"
)

Variables

View Source
var (
	MetaConns = metric.Metadata{
		Name: "sql.conns",
		Help: "Number of active sql connections"}
	MetaBytesIn = metric.Metadata{
		Name: "sql.bytesin",
		Help: "Number of sql bytes received"}
	MetaBytesOut = metric.Metadata{
		Name: "sql.bytesout",
		Help: "Number of sql bytes sent"}
)

Fully-qualified names for metrics.

Functions

func Match

func Match(rd io.Reader) bool

Match returns true if rd appears to be a Postgres connection.

Types

type Server

type Server struct {
	AmbientCtx log.AmbientContext
	// contains filtered or unexported fields
}

Server implements the server side of the PostgreSQL wire protocol.

func MakeServer

func MakeServer(
	ambientCtx log.AmbientContext,
	cfg *base.Config,
	executor *sql.Executor,
	internalMemMetrics *sql.MemoryMetrics,
	parentMemoryMonitor *mon.BytesMonitor,
	histogramWindow time.Duration,
) *Server

MakeServer creates a Server.

func (*Server) IsDraining

func (s *Server) IsDraining() bool

IsDraining returns true if the server is not currently accepting connections.

func (*Server) Metrics

func (s *Server) Metrics() *ServerMetrics

Metrics returns the metrics struct.

func (*Server) ServeConn

func (s *Server) ServeConn(ctx context.Context, conn net.Conn) error

ServeConn serves a single connection, driving the handshake process and delegating to the appropriate connection type.

func (*Server) SetDraining

func (s *Server) SetDraining(drain bool) error

SetDraining (when called with 'true') prevents new connections from being served and waits a reasonable amount of time for open connections to terminate before canceling them. An error will be returned when connections that have been cancelled have not responded to this cancellation and closed themselves in time. The server will remain in draining state, though open connections may continue to exist. When called with 'false', switches back to the normal mode of operation in which connections are accepted. The RFC on drain modes has more information regarding the specifics of what will happen to connections in different states: https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/drain_modes.md

type ServerMetrics

type ServerMetrics struct {
	BytesInCount   *metric.Counter
	BytesOutCount  *metric.Counter
	Conns          *metric.Counter
	ConnMemMetrics sql.MemoryMetrics
	SQLMemMetrics  sql.MemoryMetrics
	// contains filtered or unexported fields
}

ServerMetrics is the set of metrics for the pgwire server.

Directories

Path Synopsis
Package pgerror is a generated protocol buffer package.
Package pgerror is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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