cockroach: github.com/cockroachdb/cockroach/pkg/sql/pgwire Index | Files | Directories

package pgwire

import "github.com/cockroachdb/cockroach/pkg/sql/pgwire"

Index

Package Files

command_result.go conn.go server.go types.go write_buffer.go

Constants

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"

    // ErrDrainingNewConn is returned when a client attempts to connect to a server
    // which is not accepting client connections.
    ErrDrainingNewConn = "server is not accepting clients"
    // ErrDrainingExistingConn is returned when a connection is shut down because
    // the server is draining.
    ErrDrainingExistingConn = "server is shutting down"
)

Variables

var (
    MetaConns = metric.Metadata{
        Name:        "sql.conns",
        Help:        "Number of active sql connections",
        Measurement: "Connections",
        Unit:        metric.Unit_COUNT,
    }
    MetaNewConns = metric.Metadata{
        Name:        "sql.new_conns",
        Help:        "Counter of the number of sql connections created",
        Measurement: "Connections",
        Unit:        metric.Unit_COUNT,
    }
    MetaBytesIn = metric.Metadata{
        Name:        "sql.bytesin",
        Help:        "Number of sql bytes received",
        Measurement: "SQL Bytes",
        Unit:        metric.Unit_BYTES,
    }
    MetaBytesOut = metric.Metadata{
        Name:        "sql.bytesout",
        Help:        "Number of sql bytes sent",
        Measurement: "SQL Bytes",
        Unit:        metric.Unit_BYTES,
    }
)

Fully-qualified names for metrics.

func Match Uses

func Match(rd io.Reader) bool

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

func RegisterAuthMethod Uses

func RegisterAuthMethod(method string, fn AuthMethod, checkEntry CheckHBAEntry)

RegisterAuthMethod registers an AuthMethod for pgwire authentication.

type AuthConn Uses

type AuthConn interface {
    // SendAuthRequest send a request for authentication information. After
    // calling this, the authenticator needs to call GetPwdData() quickly, as the
    // connection's goroutine will be blocked on providing us the requested data.
    SendAuthRequest(authType int32, data []byte) error
    // GetPwdData returns authentication info that was previously requested with
    // SendAuthRequest. The call blocks until such data is available.
    // An error is returned if the client connection dropped or if the client
    // didn't respect the protocol. After an error has been returned, GetPwdData()
    // cannot be called any more.
    GetPwdData() ([]byte, error)
    // AuthOK declares that authentication succeeded and provides a
    // unqualifiedIntSizer, to be returned by authenticator.authResult(). Future
    // authenticator.sendPwdData() calls fail.
    AuthOK(unqualifiedIntSizer)
    // AuthFail declares that authentication has failed and provides an error to
    // be returned by authenticator.authResult(). Future
    // authenticator.sendPwdData() calls fail. The error has already been written
    // to the client connection.
    AuthFail(err error)
}

AuthConn is the interface used by the authenticator for interacting with the pgwire connection.

type AuthMethod Uses

type AuthMethod func(c AuthConn, tlsState tls.ConnectionState, insecure bool, hashedPassword []byte, execCfg *sql.ExecutorConfig, entry *hba.Entry) (security.UserAuthHook, error)

AuthMethod defines a method for authentication of a connection.

type CheckHBAEntry Uses

type CheckHBAEntry func(hba.Entry) error

CheckHBAEntry defines a method for error checking an hba Entry.

type Server Uses

type Server struct {
    AmbientCtx log.AmbientContext

    SQLServer *sql.Server
    // contains filtered or unexported fields
}

Server implements the server side of the PostgreSQL wire protocol.

func MakeServer Uses

func MakeServer(
    ambientCtx log.AmbientContext,
    cfg *base.Config,
    st *cluster.Settings,
    sqlMemMetrics sql.MemoryMetrics,
    parentMemoryMonitor *mon.BytesMonitor,
    histogramWindow time.Duration,
    executorConfig *sql.ExecutorConfig,
) *Server

MakeServer creates a Server.

Start() needs to be called on the Server so it begins processing.

func (*Server) Drain Uses

func (s *Server) Drain(drainWait time.Duration) error

Drain prevents new connections from being served and waits for drainWait for open connections to terminate before canceling them. An error will be returned when connections that have been canceled 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. 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/20160425_drain_modes.md

func (*Server) IsDraining Uses

func (s *Server) IsDraining() bool

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

func (*Server) Metrics Uses

func (s *Server) Metrics() (res []interface{})

Metrics returns the set of metrics structs.

func (*Server) ServeConn Uses

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.

An error is returned if the initial handshake of the connection fails.

func (*Server) Start Uses

func (s *Server) Start(ctx context.Context, stopper *stop.Stopper)

Start makes the Server ready for serving connections.

func (*Server) Undrain Uses

func (s *Server) Undrain()

Undrain switches the server back to the normal mode of operation in which connections are accepted.

type ServerMetrics Uses

type ServerMetrics struct {
    BytesInCount   *metric.Counter
    BytesOutCount  *metric.Counter
    Conns          *metric.Gauge
    NewConns       *metric.Counter
    ConnMemMetrics sql.MemoryMetrics
    SQLMemMetrics  sql.MemoryMetrics
}

ServerMetrics is the set of metrics for the pgwire server.

Directories

PathSynopsis
hbaPackage hba implements an hba.conf parser.
pgcodePackage pgcode defines the PostgreSQL 5-character support codes used throughout the CockroachDB source tree.
pgerror
pgwirebasePackage pgwirebase contains type definitions and very basic protocol structures to be used by both the pgwire package and by others (particularly by the sql package).

Package pgwire imports 52 packages (graph) and is imported by 4 packages. Updated 2019-09-16. Refresh now. Tools for package owners.