conn

package
v0.0.0-...-97394dd Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package conn contains code that supports a single pgwire proxy connection.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidToken = ErrorResponsef(
	pgerrcode.InvalidAuthorizationSpecification, "invalid JWT token")

ErrInvalidToken contains a pgwire error message.

Functions

func AsErrorResponse

func AsErrorResponse(err error) *pgproto3.ErrorResponse

AsErrorResponse locates a WrappedError within the given error message and returns the message. Otherwise, a generic "internal error" message will be returned.

Types

type Conn

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

Conn represents a single proxy connection between an incoming SQL caller and the target database.

func New

func New(cfg *config.Cache, clientConn net.Conn) *Conn

New constructs a proxy connection around the incoming network stream.

func (*Conn) IsActive

func (c *Conn) IsActive() bool

IsActive returns true if the client has sent data to the target, and no ReadyForQuery message has been sent back.

func (*Conn) IsClosed

func (c *Conn) IsClosed() bool

IsClosed returns true if the proxy connection is closed.

func (*Conn) IsDraining

func (c *Conn) IsDraining() bool

IsDraining returns true if the connection has been placed into a drain mode.

func (*Conn) Run

func (c *Conn) Run(ctx context.Context) error

Run is called after the connection has been constructed. Canceling the context will trigger a graceful drain of the connection.

type WrappedError

type WrappedError struct {
	*pgproto3.ErrorResponse
}

WrappedError wraps a pgwire ErrorResponse as an error.

func ErrorResponsef

func ErrorResponsef(code string, format string, args ...interface{}) *WrappedError

ErrorResponsef is a convenience method to return a WrappedError with a basic ErrorResponse.

func (*WrappedError) Error

func (e *WrappedError) Error() string

Error implements error.

Jump to

Keyboard shortcuts

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