faultyconn

package
v5.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// HandleFrontendMessage is called for each frontend message received. It should use backendWriter to write to the
	// backend.
	HandleFrontendMessage func(backendWriter io.Writer, msg pgproto3.FrontendMessage) error
	// contains filtered or unexported fields
}

Conn is a wrapper for a net.Conn that allows inspection and modification of messages between a PostgreSQL client and server. It is designed to be used in tests that use a *pgx.Conn or *pgconn.PgConn connected to a real PostgreSQL server. Instead of mocking an entire server connection, this is used to specify and modify only the particular aspects of a connection that are necessary. This can be easier to setup and is more true to real world conditions.

It currently only supports handling frontend messages.

func New

func New(c net.Conn) *Conn

NewConn creates a new Conn that proxies the messages sent to and from the given net.Conn. New can be used with pgconn.Config.AfterNetConnect to wrap a net.Conn for testing purposes.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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