MCPcopy
hub / github.com/jackc/pgx / New

Function New

internal/faultyconn/faultyconn.go:35–46  ·  view source on GitHub ↗

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.

(c net.Conn)

Source from the content-addressed store, hash-verified

33// NewConn creates a new Conn that proxies the messages sent to and from the given net.Conn. New can be used with
34// pgconn.Config.AfterNetConnect to wrap a net.Conn for testing purposes.
35func New(c net.Conn) *Conn {
36 fromFrontendBuf := &bytes.Buffer{}
37 fromBackendBuf := &bytes.Buffer{}
38
39 return &Conn{
40 conn: c,
41 fromFrontendBuf: fromFrontendBuf,
42 fromBackendBuf: fromBackendBuf,
43 backend: pgproto3.NewBackend(fromFrontendBuf, c),
44 frontend: pgproto3.NewFrontend(fromBackendBuf, c),
45 }
46}
47
48func (c *Conn) Read(b []byte) (n int, err error) {
49 return c.conn.Read(b)

Calls 2

NewBackendFunction · 0.92
NewFrontendFunction · 0.92